Squashing commits in the same branch

Okay, I’m sure this is documented lots of places, but I just now figured out that git rebase -i is perfectly happy to rebase from a commit on the same branch, so if you’ve got a branch that you’d like to smoosh some commits on, do a git log to get the SHA1 of the initial commit, then

git rebase -i <SHA1>

It will happily show you all the commits and you can then twiddle to your heart’s content to clean up.

Comments

Leave a Reply