Member-only story
Git Commit Squash
Squashing commits is the act of combining a few commits into one. There are two places the term “squash” appears, in the context of git:
- Squash merge
- Manual squash
The squash merge is a special type of merging, that automatically takes all of the commits in one branch, squashes them together, and adds the result commit into the target branch (usually master).
Squash merge is partially addressed in the following issue of Git Weekly:
In this issue, we’re going to talk about the ways one squashes a few commits together manually.

Manual Squash
Manual squash is possible through “interactive rebasing”. Let’s assume we want to squash 5 last commits together. We’ll then do an interactive rebase on the last 5 commits:
git rebase -i HEAD~5
This command will start the interactive rebase. An editor (e.g. nano
) with content similar to what follows will launch:
pick f72e7cb Feat: Resurrect flatMap
pick 1a18b1c Feat: Add list transformations
pick 3420af4 3.0.0
pick f55a9ee Docs: Add marble diagrams to README
pick 0433f9d Update README.md