Last Updated: February 25, 2016
·
821
· jisaacks

git - squish commits w/o rebasing

git reset head~n  
git add -A  
git commit -m "new commit message"  

Where n is the number of your last commits you want to merge

For example if you want to merge your last 3 commits into 1:

git reset head~3  
git add -A  
git commit "I merged my last 3 commits"  

Caveats:

  • This only works if all n commits are the last n commits in the repo.
  • Any changes to your working directory will also be committed so only do this when you have a clean working tree.