Git merge squash


This article goes over how to merge Git commits with squash.

Squash

Given the branches:

git branch
* feature
  master

To merge feature into master with a squash commit:

git checkout master
git merge --squash feature
git commit -am "feat: add feature"

Alternatively, you can set the commit message during squash:

git merge --squash feature -m "feat: add feature"

However, the commit message will look like:

squash! Merge branch 'feature' into master

feat: add feature

If you don’t like that, you can amend the commit message:

git commit --amend -m "feat: add feature"


Please support this site and join our Discord!