Find the SHA of the commit you want squash to
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.
Cntl-v enter visual mode
c – to delete
Type what you want to appear
Press ‘Esc’ x2
Add a ‘p’ to top commit (reverse order)
Then voila! Du ar klar! Force push in.
git push --force -n
And push back to your master
git checkout <master> git merge <branch>
If you make a mistake
git rebase --abort
If you want to change a commit message
git commit --amend
Two squash two commits together:
git rebase --interactive HEAD~2
Dont reorder. Just take as is and change commit message when done.