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
One of:
$ git checkout topic $ git rebase master
or:
$ 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
$ git rebase --onto master next topic
o---o---o topic / o---o---o---o---o master \ o---o---o---o---o next
Given:
A <--- B <--- C <--- D <--- E <--- F [HEAD]
we could remove C and D with:
$ git rebase --onto B D [HEAD]
to get:
A <--- B <--- E' <--- F' [HEAD]