Last Updated: February 20, 2016
·
481
· willrax

Using git rebase to merge commits

Last week I needed to merge 4 commits and used ** git rebase **

This is an absolutely terrible thing to do if you are collaborating with others.

git rebase -i HEAD~4

This will open up your default text editor where you can 'pick' which commits to keep and which to squash.

Save the file and off you go. Make sure you

git push -f origin master

if all is lost then you can always run

git rebase --abort