dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Merge two completely separate commit histories

Open timsehn opened this issue 3 years ago • 2 comments

Right now, to merge, the two branches must share a common commit ancestor. This is not strictly necessary as you can materialize an artificial ancestor before both init commits and run the merge as normal. This comes up every so often in customer discussions. Cataloguing as an issue.

timsehn avatar Oct 05 '22 21:10 timsehn

In Git this must be enabled by a flag:

--allow-unrelated-histories
By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.

https://www.git-scm.com/docs/git-merge/2.18.0#:~:text=By%20default%2C%20git%20merge%20command,that%20started%20their%20lives%20independently.

Which I think is a reasonable approach for Dolt.

timsehn avatar Aug 22 '23 15:08 timsehn

At the same time we do this we may also want to implement dolt branch --orphan/dolt checkout -b --orphan.

https://git-scm.com/docs/git-checkout/2.14.6#Documentation/git-checkout.txt---orphanltnewbranchgt

timsehn avatar Apr 12 '24 18:04 timsehn