开发者

Git merge - trivial merge?

If the base and the source have the same file content, and th开发者_高级运维e destination branch/repo has some other file changes, which content does it keep, the source or the destination file?

To explain in detail

       A 
       | 
       B 
      / \
     C   D 

Suppose that a file was added on the A->B edge, and then removed again in B->C, while it was left alone on the B->D edge.

We want to merge C and D.

If the common ancestor is A which doesn’t have the change (so A,C don’t have the file & B,D has the file) when merging C and D.

What happens if C (destination) merges from D?

What happens if D (destination) merges from C?


Merge is symmetric (aside from the fact that the merge ends up on one branch or the other). It will apply changes from both sides and report any conflicting changes it encounters in the process. In this case, since only one side has changes, the end result will look identical to the side that has the changes.

As an aside, you can try these operations quite safely to see what they will do; if things go pear-shaped, just undo. Be sure to note the caveats at the bottom of the linked article, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜