Squash
Squashing commits is a technique used in Git to merge multiple
commits into a single commit. This is helpful in keeping a clean Git history.
Services like GitHub can squash pull requests, which
combines all the commits from a pull request into a single commit. To squash
commits, the rebase command is used with the -i
flag followed by the
number of commits to be squashed:
git rebase -i HEAD~<number-of-commits>
Since squashing commits modifies the Git history, the -i
flag needs to be used
for an ‘interactive’ rebase which allows the user to edit the commit history.