hlitz
hlitz

Reputation: 655

Git merge 2 versions no common ancestor

I have my source code in a mercurial repo, whereas the master branch has been moved from mercurial to a git repo. The current git master branch head and my mercurial version has conflicts. The git master was created as a new repo and not derived from the original mercurial repo. How can I merge my modifications with the master branch's modifications?

If I create a new branch from the master, overwrite the sources with my mercurial sources and merge it with the master, git doesn't detect conflict (I suppose because we have no common ancestor version)

Upvotes: 2

Views: 1567

Answers (1)

Edward Thomson
Edward Thomson

Reputation: 78813

I wouldn't think that it would. If you create a new branch from master then you do in fact have a common ancestor, and that common ancestor is in fact, master itself. This means that the merge result is actually your new branch, since it's a fast-forward from master.

If you were to create a new branch with no history (or no relationship to master) then you would get the merge conflicts you expect. You can create a new orphan branch:

git checkout --orphan new_branch

And then copy your sources in from mercurial, you will be able to merge with master. Any files that are not identical between the two branches will be marked as conflicts.

Upvotes: 2

Related Questions