Outofdate
Outofdate

Reputation: 695

New lines at end of files merge conflict

I work on an android project with my colleague where we have a strings.xml file for a strings in our app. So every time when we put new strings at the end of the file together we run into conflict while merging. I though it was supposed that git can automatically distinguish if those were new lines or changes. How can i resolve this? For note that we are using Ubuntuenter image description here

Upvotes: 1

Views: 1612

Answers (3)

Andrea Reina
Andrea Reina

Reputation: 1240

If the order of the entries doesn't matter you can have a convention to keep the strings in alphabetical order.

Upvotes: 0

Keif Kraken
Keif Kraken

Reputation: 10660

It sounds like you're working on a project with 1 other person (or at least on a small team). If you're just adding to an XML file, the order wouldn't matter so you could maybe by convention that you add new XML lines at the top and have them add their new lines at the bottom.

The merge conflict is the correct outcome because you're trying to add new data at the same lines with different values, but if you're adding your new data at a different place, then there wouldn't be a conflict and it would automatically add both of your lines.

Upvotes: 0

Ankit Bhatnagar
Ankit Bhatnagar

Reputation: 755

I've encountered same thing in my project also. It's very logical for git to give a conflict on such scenarios as there are non empty lines present after the concerned change set. One thing that we follow for all such files is that we try to add a method/function or a tag somewhere in between the file and not at the end of it. Then the change line becomes different and conflict doesn't come.

Upvotes: 1

Related Questions