merge - Conflict when merging two branches with git -


i have problem merging 2 branches. have xml file following content:

<?xml version="1.0" encoding="utf-8"?> <language xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" name="sk" xsi:nonamespaceschemalocation="language.xsd">   <topic name="topicname">     <section name="sectionname">       <pair key="key_1" state="0">value 1</pair>       <pair key="key_2" state="0">value 2</pair>     </section>   </topic> </language> 

then following case:

the branch "master" changes @ xml file "state" "0" "1". i.e.

<?xml version="1.0" encoding="utf-8"?> <language xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" name="sk" xsi:nonamespaceschemalocation="language.xsd">   <topic name="topicname">     <section name="sectionname">       <pair key="key_1" state="1">value 1</pair>       <pair key="key_2" state="1">value 2</pair>     </section>   </topic> </language> 

the changes commited , pushed te cenral repository.

the branch "test" addes new node. i.e. :

<?xml version="1.0" encoding="utf-8"?> <language xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" name="sk" xsi:nonamespaceschemalocation="language.xsd">   <topic name="topicname">     <section name="sectionname">       <pair key="key_1" state="0">value 1</pair>       <pair key="key_2" state="0">value 2</pair>       <pair key="key_3" state="0">value 3</pair>     </section>   </topic> </language> 

the changes commited , pushed te cenral repository.

when merge "test" branch @ "master" branch conflict. i.e.

[master] git pull origin test 

the conflicted file looks this:

<?xml version="1.0" encoding="utf-8"?> <language xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" name="sk" xsi:nonamespaceschemalocation="language.xsd">   <topic name="topicname">     <section name="sectionname"> <<<<<<< head       <pair key="key_1" state="1">value 1</pair>       <pair key="key_2" state="1">value 2</pair> =======       <pair key="key_1" state="0">value 1</pair>       <pair key="key_2" state="0">value 2</pair>       <pair key="key_3" state="0">value 3</pair> >>>>>>> b872e7d1bbbe281482baefa73e322a34c475aa92     </section>   </topic> </language> 

i don't understand why these kind of changes lead conflicts. can assure there no other changes on files, spaces, tabs or new lines. (i have reproduced kind of conflict many times)

when open conflicted file merge tool, shows no conflict. shows changes, , merge tool not automatically merge new line. (i use git version 1.7.10.4)

can explain why happens , how can avoid kind of conflicts.

thanks in advance.

edit: searching better merge-tools resolving git-conflicts. found kdiff3. when did command:

git mergetool --tool kdiff3 sk.xml 

the tool did not show, did resolved conflict automatically. happy.

now questions:
1. why can not git this?
2. can "kdiff3" trusted, solved conflict good? checked manually type of conflict posted, , solved conflict good. there potentiall that, tool may merge files automatically unproperly?

while humans recognize 1st branch changed 0 character on each of pair of lines 1, diff/merge tools don't see things way. these programs line oriented.
2 lines deleted. 2 new lines inserted in there place. similarity irrelevant.

the 2nd branch inserts line, where? know it's before </section> line, 2 lines before cited deletion other branch. thing that's same <section ... > line.

a human might reasonably guess new key_3 line should inserted after 2 new key_1 & key_2 lines, there's no reasonable way programmaticly sure of that.

erring on side of caution not unreasonable.

avoiding require byte/character oriented diff tools, there prices too.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -