Reputation: 8159
Say I have branch branch-1
based on somewhere back in master
, and another branch branch-1a
which is based on the latest commit of branch-1
. I want to rebase branch-1
and branch-1a
simultaneously onto the top of master.
What's the best way of doing that?
Graphically I want to go from:
----o---o---o---o - master
\
o---o---o---o - branch-1a
`branch-1
to
----o---o---o---o - master
\
o---o---o---o - branch-1a
`branch-1
I know that I could rebase branch-1a
and then check out branch-1
and force reset it on to the correct commit, but that is tedious and I was hoping there might be a one command solution.
Upvotes: 0
Views: 135
Reputation: 4476
You will have no other choice to do it one by one:
Rebase branch1
on top of master
:
git checkout branch1
git rebase master
Rebase branch1-a
on top of branch1
:
git checkout branch1-a
git rebase branch1
And so on if you have other branches.
Always rebase them on top of their closest base and in this order.
Upvotes: 1
Reputation: 137084
I'm not aware of a single command to rebase all of them, but you can use --fork-point
to simplify later rebases:
git checkout branch-1
git rebase master
git checkout branch-1a
git rebase --fork-point branch-1
Without --fork-point
(or manually identifying the commit that branch-1
used to point to) you would see two commits duplicated:
----o---o---o---o - master
\
x---y---x'---y'---o---o - branch-1a
`branch-1
--fork-point
tells Git to use the reflog, which should help it recognize that those pairs of commits are "the same" and exclude them from the second rebase.
Upvotes: 2