Different behaviour for --find-renames between git diff and git merge?
- From
- Luca Balsanelli <lucabalsanelli@gmail.com>
- Date
- Dec 12, 2025, 18:04 UTC
- Message-ID
- <3742e7de-7d88-4e77-b711-9fed867a8c23@gmail.com>
Hi,
I'm scratching my head to understand why on the following case `git diff` and `git merge` give a different interpretation about a rename.
git switch master
touch aaa
git add aaa
git commit -m 'aaa' git switch -c branch
echo -en 'A\nB\nC\n' > aaa
git add aaa
git commit -m 'A\nB\nC\n > aaa' git switch master
echo -en 'A\nB\n' > aaa
mkdir dir
mv aaa dir/
git add aaa dir/
git commit -m 'A\nB\n > aaa -> dir/'The `|merge.renames` config variable is true. Changing `git diff --find-renames=50%` (the default) or `git merge -s ort -X find-renames=50%` ||to something lower does not change the following. |
`git diff` prints
diff --git a/aaa b/dir/aaa
similarity index 71%
rename from aaa
rename to dir/aaa
index bbd2b90..986ad36 100644
--- a/aaa
+++ b/dir/aaa
@@ -1,4 +1,3 @@
A
B
-Cthat is the similarity index is 71% and it detects the rename.
`git merge branch`, instead, gives
CONFLICT (modify/delete): aaa deleted in HEAD and modified in
branch. Version branch of aaa left in tree.
Automatic merge failed; fix conflicts and then commit the resultWhy it is that? I always supposed that the rename detection was the same for `git diff`, `git merge`. Reading the documentation I do not find any hint why `git diff` and `git merge` are behaving differently.
Thanks,
Luca Balsanelli