[ad_1]
The way I remember it is as an English sentence:
rebase (from) old_parent (up to) branch_tip onto new_parent
That is:
git rebase old_parent branch_tip --onto new_parent
(Note that the arguments are in a different order to how some people write them; the --onto new_parent
is an option, not a positional argument, so can go anywhere, and I just find it more logical at the end rather than the beginning.)
In your case:
old_parent
is the commit hash shown on your diagram asH
branch_tip
isbranch-B
(and defaults to the currently checked out branch)new_parent
isI
AKAorigin/main
So look up the actual commit hash for commit “H”, and run:
git rebase H branch-B --onto origin/main
Or:
git switch branch-B
git rebase H --onto origin/main
Or if you prefer to put the --onto
first:
git switch branch-B
git rebase --onto origin/main H
[ad_2]