简体   繁体   English

git工具无法读取git的合并结果

[英]git merge result cannot be read by diff tool

I am trying to figure out what is happening when I am merging git branches. 我试图弄清楚合并git分支时发生的情况。 I have a branch that has diverged ( feature_1 ) from the main branch ( develop ). 我有一个分支与主要分支(development)不同(feature_1)。 I do a merge 我合并

git merge develop

and i get some expected conflicts 我得到一些预期的冲突

CONFLICT (add/add): Merge conflict in res/values/dimens.xml
Automatic merge failed; fix conflicts and then commit the result.

the status of the that file is this: 该文件的状态是这样的:

$ git diff res/values/dimens.xml
diff --cc res/values/dimens.xml
index ec31f04,554d1e7..0000000
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@@ -1,5 -1,4 +1,11 @@@
++<<<<<<< HEAD
 +<resources>
 +    <dimen name="left_nav_side">120dip</dimen>
 +    <dimen name="left_nav_vertical_margin">30dip</dimen>
 +    <dimen name="third_left_nav_vertical_margin">10dip</dimen>
++=======
+ <?xml version="1.0" encoding="utf-8"?>
+ <resources>
+     <dimen name="round_corner">4dp</dimen>
++>>>>>>> develop
  </resources>

it seems there are two types of "diffs" in this file, the ones with the pluses/minuses and the one's with the arrows with "HEAD". 在该文件中似乎有两种“差异”,一种具有加/减号,一种具有“ HEAD”箭头。 When I open it up in a merge tool like meld i get something that I don't think is right: 当我在像meld这样的合并工具中打开它时,我得到了一些我认为不正确的信息: 融合屏幕截图

As you can see the working tree changes show up as a diff and show the markers as part of the file which I don't think they should. 如您所见,工作树的更改显示为差异,并且标记显示为文件的一部分,我认为它们不应该。 I get something similar with the IntelliJ "resolve conflicts" tool. 我使用IntelliJ“解决冲突”工具得到了类似的结果。 Can someone tell me what I have done wrong or what I am missing? 有人可以告诉我我做错了什么或我想念什么吗? Or maybe can you just tell me what is going on in the file? 或者,也许您可​​以告诉我文件中发生了什么?

The file itself contains the conflict markers; 文件本身包含冲突标记。 it looks like this: 它看起来像这样:

<<<<<<< HEAD
<resources>
    <dimen name="left_nav_side">120dip</dimen>
    <dimen name="left_nav_vertical_margin">30dip</dimen>
    <dimen name="third_left_nav_vertical_margin">10dip</dimen>
=======
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="round_corner">4dp</dimen>
>>>>>>> develop
</resources>

The merge has stopped in between commits to give you a chance to fix the problem, so if you diff the file it's going to show the changes between the file and the last commit, which shows all the new stuff in that commit, plus the conflict markers that git added to the file 提交之间的合并已停止,从而使您有机会解决此问题,因此,如果对文件进行diff ,它将显示文件与最后一次提交之间的更改,这将显示该提交中的所有新内容以及冲突git添加到文件中的标记

What you actually want to do is edit the file, resolve the conflicts, remove the markers, and then git add res/values/dimens.xml; git commit 您实际要做的是编辑文件,解决冲突,删除标记,然后git add res/values/dimens.xml; git commit git add res/values/dimens.xml; git commit to fix the conflicted commit git add res/values/dimens.xml; git commit修复冲突的提交

The conflict markers are always a part of the file its correct as it is. 冲突标记始终是文件正确的一部分。 The markers are not only used by git, for example netbeans uses the markers too. 这些标记不仅由git使用,例如netbeans也使用这些标记。 With the markers a external programm knows that there is a merge problem and how to solve it. 使用标记,外部程序会知道存在合并问题以及如何解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM