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

If you have a conflict, fix the conflict then…

git add .
git rebase --continue

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
git reset --soft HEAD~2 &amp;&amp; git commit</pre>

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.

Rebase master

Then when ready to run master onto of your changes on your local branch.

git rebase master