How do I create a criss-cross merge in Git?

2019-09-06 19:56发布

问题:

I have to test a bug fix and I need to create a criss-cross merge between two branches. There isn't much documentation and I am fairly new to Git. I'm not submitting code, just testing the functionality of our code review system.

The single file I am using to make changes is a simple Read me text file.

回答1:

When the history involves criss-cross merges, there can be more than one best common ancestor for two commits. For example, with this topology:

---1---o---A
    \ /
     X
    / \
---2---o---o---B

The above comes from the git website, I guess it forgets about adding an arrow.

Let's look at the pic below, it is obvious how to make a criss-cross situation then. when branch A needs some code from branch B, it merges from branch B; when branch B needs some code from branch A, it mergers from branch A; here we come across the criss-cross situations then.

Even more, It is easy to figure out that branch A and branch B share ancestors 1 and 2.



回答2:

You're talking about this scenario: http://www.gelato.unsw.edu.au/archives/git/0504/2279.html

I also tried to reproduce what happens there, but git doesn't fail with an error, I think it switches to resolve strategy which maximizes conflicts, at least that's what git(vers 1.8.3.rc1) gave me to solve when I reproduced it.