Squash Merge vs Fast-Forward Merge
People think a squash merge and a fast-forward are the same, because both leave main in a straight line. They are not. A fast-forward makes no new commit. Main's label just slides onto the branch's own commits, so every one of them is kept. A squash merge makes one new commit for the whole branch, and the branch's own commits stay off main.
Squash Merge
Merging a branch as one commit. Main's history stays short.
A squash merge turns all the commits on a branch into one new commit. That one commit lands on the target branch. The small steps, like typo fixes, do not show up in main's history. GitHub offers this as Squash and merge on a pull request. The branch's own commits are not kept on main.
Fast-Forward Merge
A merge where Git just slides the branch forward. No merge commit is made.
A fast-forward merge happens when the target branch has not moved since the other branch split off. There is nothing to combine. Git just moves the branch label forward to the newest commit. No new merge commit is made, and the history stays in one straight line. If both branches have new commits, a fast-forward is not possible.
In one line
- Squash Merge
- Merging a branch as one commit. Main's history stays short.
- Fast-Forward Merge
- A merge where Git just slides the branch forward. No merge commit is made.