Find the SHA of the commit you want squash to

Screen Shot 2017-03-02 at 9.23.34 AM.png

If we want to squash all our work down to Story X, we need to go one beyond and grab the SHA from the one after the one we want to squash down to.

Screen Shot 2017-03-02 at 9.24.44 AM.png

Cntl-v enter visual mode
Select text
c – to delete
Type what you want to appear (s)
Press ‘Esc’ x2
Add a ‘p’ to top commit (reverse order)
Save (:wq)

Screen Shot 2017-03-02 at 9.28.19 AM.png

Screen Shot 2017-03-02 at 9.29.07 AM.png

Screen Shot 2017-03-02 at 9.29.27 AM.png

Then voila! Du ar klar! Force push in.

git push --force -n

If you make a mistake

git rebase --abort

If you want to change a commit message

git commit --amend

If you want to add another author to a commit

git commit --amend --author "peter+paul <>" -C HEAD
git commit --amend
git push -f

Squash specific number of commits together

Screen Shot 2017-04-10 at 9.30.54 AM.png

If you want to squash say x3 commits together to this

git rebase --interactive HEAD~3

And that will produce this

Screen Shot 2017-04-10 at 9.34.49 AM.png

So when you go ~3 it squashes three down into one. But doesn’t affect the one before it.