Is there a way to squash a number of commits non-interactively?

Phillip picture Phillip · Sep 1, 2011 · Viewed 47.5k times · Source

I'm trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive?

Answer

wilhelmtell picture wilhelmtell · Sep 1, 2011

Make sure your working tree is clean, then

git reset --soft HEAD~3
git commit -m 'new commit message'