September 26, 2020
I run into this every couple of weeks:
dev
to make feature-1
feature-1
up for code review, and start working on feature-2
by branching from feature-1
feature-1
is eventually merged into dev
, so feature-2
’s commits need to change to be on top of dev
as wellgit rebase --onto dev feature-1 feature-2
assuming you already have branch feature-2
checked out (because you are actively working on it), you can remove the last argument (the target branch to change)
git rebase --onto dev feature-1
so it reads like:
git rebase --onto <to> <from> <branch-to-manipulate>
I like this quote:
The current branch is reset to <upstream>, or <newbase> if the —onto option was supplied. This has the exact same effect as
git reset —hard <upstream>
(or <newbase>). ORIG_HEAD is set to point at the tip of the branch before the reset.
tags: git