Git Squash
To squash is to combine several commits into a single commit, so the history shows one clear change instead of many small steps.
You can squash a whole branch with git merge --squash, or pick the commits to combine with git rebase -i. GitHub can also squash a pull request when you merge it.
Squash a branch into one commit
git merge --squash fix-typos
Updating 97c9c49..f3daf30
Fast-forward
Squash commit -- not updating HEAD
index.html | 2 ++
1 file changed, 2 insertions(+)
git commit -m "Fix typos in index.html"
[main d9b2715] Fix typos in index.html
1 file changed, 2 insertions(+)
git log --oneline -2
d9b2715 Fix typos in index.html
97c9c49 First release of Hello World!
Squash with an interactive rebase
Run git rebase -i HEAD~3, then in the editor change pick to squash for the commits to fold into the one above them:
pick 6bd927a Fix typo 1
squash 43c55b4 Fix typo 2
squash bc88b7c Fix typo 3