Alister West

home is where your code is ...

Git Squash

A quick reference for me and squashing a git-branch into 1 commit.

Workflow I actually use: Squash during merge

git merge --squash <feature_branch>
git commit -a

Squash commits 1. Rebase

# Don't use if you have merged master into dev as you will
# have to find the original branch point SHA1
git checkout -b dev_squash
git rebase -i master (pick commits)
git checkout master
git merge dev_squash

Squash commits 2. Unstage.

git checkout master
git merge dev
git reset origin/master
# Now all changes are unstaged
git add .
git add -u # The -u option also adds file deletions.
git commit


  • "squash commits":
By Alister West