Git rebase --onto

Updated . Posted . Visible to the public.

It seems like everyone needs their own explanation of how git rebase --onto works. Here's a very short one :) For details see the linked article.

git rebase --onto can be invoked with two or three arguments. With two arguments the general syntax looks like this:

git rebase --onto <newparent> <oldparent>

This will allow us to change the current parent <oldparent> to new one <newparent>.

git rebase --onto <newparent> <oldparent> <until>

Now we can change the old parent <oldparent> to new one <newparent>, but we will take commits (from our current branch) only until <until> commit. Remember <until> will become the new HEAD after rebase is completed. All commits after <until> will no longer be part of the branch.


<oldparent> : The commit before the commit you want to use. You can get that easily with ~ .e.g the commit you want to use is 1234, then use 1234~.

Judith Roth
Last edit
Judith Roth
Posted by Judith Roth to Judith's Dev Notes (2021-06-26 12:06)