Reputation: 6467
Firstly, I imagine this is duplicate; I'm guessing there's a name for what I'm trying to do, but I can't find anything about it.
Imagine I have commits:
a1 -- a2 -- b1 -- b2 -- c1 -- c2
Where a
, b
, and c
are branches. I'm trying to get the history so that it is:
- b1 -- b2
/
a1 -- a2 -- c1 -- c2
But if I try and rebase c
onto a
, I understandably get b
as well.
Is there a good way to do this?
Upvotes: 0
Views: 445
Reputation: 23144
These are multiple steps. The basic operation is git rebase --onto <newbase> <oldbase> <tip>
(where newbase
and oldbase
can be commit hashes or branch names, but tip
should be a branch name).
I'm assuming you have branches b
and c
pointing to commits b2
and c2
, respectively.
git rebase --onto a2 b2 c
Result:
- b1 -- b2
/
a1 -- a2 -- c1 -- c2
Note that b1
and b2
are still unchanged, I just had to move them up visually.
git rebase --onto a1 a2 b
Result:
- b1 -- b2
/
a1 -- a2 -- c1 -- c2
Upvotes: 4