0

I am trying to figure out what is happening when I am merging git branches. I have a branch that has diverged ( feature_1 ) from the main branch ( develop ). 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". When I open it up in a merge tool like meld i get something that I don't think is right: meld screenshot

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. 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?

browep
  • 5,057
  • 5
  • 29
  • 37

2 Answers2

0

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

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 to fix the conflicted commit

Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
  • i understand that part. I guess what I am confused about is why meld would show the conflict markers as part of the file, should it not show me the conflict options and which ones I want to choose? – browep Mar 27 '12 at 01:23
0

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. With the markers a external programm knows that there is a merge problem and how to solve it.

SG 86
  • 6,974
  • 3
  • 25
  • 34
  • a mergetool like meld? thats a SS from meld above, its showing the actual diff markers instead of the what the diff markers represent. – browep Mar 27 '12 at 15:32