Three commit references when merging submodules

允我心安 提交于 2019-12-08 06:26:13

问题


I am merging a branch in a project that uses git submodules. Usually when there is a conflict there are two sets of changes, theirs and ours. Resolving the conflicts is about merging these two into one. But I noticed that for git submodules the diff shows a third value:

diff --cc my_submodule
index dd7404e,e6753b1..0000000
--- a/my_submodule
+++ b/my_submodule
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit dd7404e5f35ee0b0064f0d6ed8201cc39d6ed6b2
 -Subproject commit e6753b1142cf0350608720ff23f7ecf51b813cd9
++Subproject commit 3b4e75fbb7c55cf21e19509bbbbfabfa1fc10630

What do the "- ", " -" and "++' mean?

Note that it's possible that the submodule version actually checked out in the repository before the merge was neither theirs nor ours, would that explain the three hashes?


回答1:


It simply means the submodule gitlink (the special entry in the index of the parent repo) was changed both in source and destination.
(See git diff man page)

++ means one line that was added does not appear in either branch1 or branch2

From Git Tools - Advanced Merging:

You have three SHA1 because in a conflict, Git stores all of these versions in the index under “stages” which each have numbers associated with them.

  • Stage 1 is the common ancestor,
  • stage 2 is your version and
  • stage 3 is from the MERGE_HEAD, the version you’re merging in (“theirs”).

The combined diff format section has all the details:

When shown by git diff-files -c (combined diff of merged files), it compares the two unresolved merge parents with the working tree file

I.e.

  • file1 is stage 2 aka "our version",
  • file2 is stage 3 aka "their version".

A - character in the column N means that the line appears in fileN but it does not appear in the result.
A + character in the column N means that the line appears in the result, and fileN does not have that line".

In your case:

  • A - in the first column means file1, meaning stage 2, meaning "ours" version.
  • A - in the second column mean file2, meaning stage 3, meaning "theirs".
  • A '++' means an addition which was not in file1 or 2 (each time when compared with the common ancestor from stage 1)


来源:https://stackoverflow.com/questions/41151216/three-commit-references-when-merging-submodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!