0

I don't understand how added by them and added by us can cause conflict,

does anyone know how to reproduce these conflicts?

user3698446
  • 107
  • 6
  • Sure. Two people make different changes to the same file, then try to commit them. Why do you intend to reproduce it? Do you want to resolve it, instead? – Makoto Aug 07 '14 at 03:20
  • @Makoto,AFAIK that will only cause `both modified` conflict, also known as content conflict, what I'm doubting about is tree conflict. – user3698446 Aug 07 '14 at 03:22
  • Tree conflict it's about moved/missing files, so tree conflict is better named filesystem tree conflict. – Silviu Burcea Aug 07 '14 at 03:51

1 Answers1

1

It looks like you're describing (according to Github) a move-move conflict.

Here's how it goes down.

You have two developers, Adam and Bob. Adam sees a resource file called tax_db.txt and decides that the file is misnamed - it's just a tab-delimited file - so he renames it to something "better", like tax_file.txt.

Bob sees the same file, and decides that it's misnamed too, but doesn't like the idea of calling it a file; it's really more of a reference. So, he names the file to tax_reference_chart.txt.

They've both got their own branch off of master (for simplicity's sake, A and B), and they're working happily oblivious to one another's changes, which have caused the project to become divergent from one another.

When Makoto, the release manager, wants to merge Adam and Bob's branches in, he would get this conflict.

makoto@workspace:~/foo$ git merge A
Updating d2cfb22..a512859
Fast-forward
 tax_db.txt => tax_file.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tax_db.txt => tax_file.txt (100%)
makoto@workspace:~/foo$ git merge B
CONFLICT (rename/rename): Rename "tax_db.txt"->"tax_file.txt" in branch "HEAD" rename "tax_db.txt"->"tax_reference_chart.txt" in "B"
Automatic merge failed; fix conflicts and then commit the result.
makoto@workspace:~/foo$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)

    both deleted:       tax_db.txt
    added by us:        tax_file.txt
    added by them:      tax_reference_chart.txt

no changes added to commit (use "git add" and/or "git commit -a")

At that point, it's basically a trip over to Adam and Bob's desk to hear arguments as to why their rename of the file was justified.

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • Is there a good way to merge this kind of conflict except go over both files line by line? – user3698446 Aug 07 '14 at 03:38
  • The contents of the file never changed; only the name of the file. In a merge conflict situation, one side has to win, so either Adam or Bob would have to convince Makoto that the rename was a good idea. Or, Makoto could whack both of them on the head, tell them to keep the old name, and force them to fix their issue. – Makoto Aug 07 '14 at 03:46
  • I'm talking about a more complex situation, say, both branch move and modified the same file.This actually happened in our project, which is across 2 countries. – user3698446 Aug 07 '14 at 03:47
  • Well, that's even nastier. (Git just created two files instead of treating them like they're the same file.) You'd take basic precautions (again, talking to the people about why the rename was a good idea), and ultimately force them to fix the rename. If the file was updated too, then you could deal with that like you would any typical merge conflict - see if both changes are necessary and resolve the conflicts manually, with or without the aid of a merge tool. – Makoto Aug 07 '14 at 03:50