When you run git merge
, git:
Finds some common / shared starting-point. This is another commit, somewhere in history, from which both "you" (the person running git merge
) and "they" (whoever produced the commit you're merging) started.
Compares the entire contents of the merge base to your current commit. These are "your changes". In your case, you changed an existing file, liste.txt
.
Compares the entire contents of the merge base to their commit. These are "their changes". In their case, they removed an existing file, liste.txt
, and created an entirely different file, listes/listes.txt
.
Combines—or attempts to combine—these two sets of changes.
Conflicts occur when the changes cannot be combined automatically using the simple rules that Git has built in. Here, the two changes that cannot be combined are:
- you modified some file;
- they removed that file entirely.
Git calls this a "modify/delete conflict".
Now, you claim that they renamed liste.txt
to listes/listes.txt
. On what basis do you make this claim? If the file contents of listes/listes.txt
were exactly the same as the file contents of the former, now-deleted liste.txt
, I might agree with you—and so might Git. If your basis for this claim is that liste.txt
and listes.txt
are sufficiently similar, well, I don't see that off-hand. Git doesn't see it either. Once you point out that if we replace line 3 and make medium-small changes to lines 1 and 2, this degree of changing would alter the contents of liste.txt
to match those in the new file listes/listes.txt
, then I might agree—and so might Git.
In the end, what Git does with this, to decide whether some file was renamed, is to compute what Git calls a similarity index. If the similarity index of the old file and the new file is high enough—meets or exceeds a 50%-similar threshold—Git will declare that the file was renamed, rather than deleting the left-side file (liste.txt
) and creating an entirely new and different right-side file (listes/listes.txt
).
You can control this rename similarity threshold, using -X find-renames=number
. You can also, as in matt's answer, disable rename detection entirely, using -X no-renames
. That's useful if Git is mis-classifying something as a rename when it shouldn't—but if there are some renames that Git should find, you'll have to deal with them yourself.
In general, Git's similarity detection works pretty well on large files. The reason it works so poorly on your sample file is that your sample file is tiny, and too many lines are too different.