simshadows

git Cheatsheet

Rebase

git rebase origin/master

More complex example:

git rebase --onto origin/master foo bar

“Take the bar branch, figure out the patches since it diverged from the foo branch, and replay those patches in the bar branch as if it was based directly off the origin/master branch instead.”

Squash the last N commits

To squash the last 3 commits:

git rebase -i HEAD~3

In the following screen, leave the top commit as pick, and set all of the remaining as squash.