This is an old revision of the document!
Simple and advanced examples of rebasing.
$ git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] [<upstream> [<branch>]] $ git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] --root [<branch>] - $ git rebase --continue | --skip | --abort | --quit | --edit-todo | --show-current-patch
Three components define a rebase:
A---B---C topic / D---E---F---G master
$ git rebase master topic
A'--B'--C' topic / D---E---F---G master
o---o---o---o---o master \ o---o---o---o---o next \ o---o---o topic
If <branch> is specified, git rebase will perform an automatic git checkout <branch> before doing anything else. Otherwise it remains on the current branch.
In other words, the final optional argument [branch]
can always be omitted if you first just:
$ git checkout <branch>
then just pretend it says HEAD
.
Given:
A <--- B <--- C <--- D <--- E <--- F [HEAD]
we could remove C and D with:
$ git rebase --onto B D
to get:
A <--- B <--- E' <--- F' [HEAD]