Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rebase onto branch without common ancestor

Tags:

git

git-rebase

I have a tree that looks as follows:

A--B (master)

C (newbase)

It contains two branches without common ancestor. Commit C is in fact a baseline for A, a guy who was importing it from old control version system just had forgotten to import it.

I would like to rebase branch so it would look as follows:

C--A--B

I tried

git checkout master
git rebase --onto newbase A -s recursive -Xtheirs

but it results in

C--B
like image 223
nkdm Avatar asked Dec 01 '25 15:12

nkdm


1 Answers

You need to use git rebase --root (plus whatever additional options you like, in this case your --onto and strategy options).

(I have only tested this with interactive rebase, but it is documented as working with all forms of rebase.)

like image 66
torek Avatar answered Dec 04 '25 05:12

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!