Disable Git Rename Detection

  • I have a file, foo.txt
  • Creating and checking the branch 'branch_A'
  • git mv foo.txt bar.txt , then git add -A , then git commit -m "renamed foo.txt"
  • git checkout master
  • delete foo.txt and commit.
  • Now merging branch_A, git merge branch_A

And with this I get a merge conflict (rename / delete).

 CONFLICT (rename/delete): Rename foo.txt->bar.txt in branch_A and deleted in HEAD 

It makes sense and I expect. However, I would like to know if there is a way for git merge to not detect renames, but instead treat them as added / deleted. In this case, I would expect git to detect that foo.txt has been removed, and just add bar.txt. There are no conflicts.

I tried using -X rename-threshold, but it did not work for me. I tried thresholds 0 and 120 (number above 100). What am I missing?

Thank!

PS I also get errors error: refusing to lose untracked file at... What does it mean?

+7
git merge rename
May 16 '11 at 4:47
source share
2 answers

You can try:

 git merge -s resolve branch_A 

In addition, you tried to look for similar questions here:

git rename / delete confusion

git divergent renaming

+7
May 16 '11 at 5:27
source share

With git 2.8 (March 2016) you will have another option (as an option for a recursive merge strategy)

 git merge -Srecursive -Xno-renames 

See commit 44c74ec , commit 2307211 , commit 63651e1 (February 24, 2016), commit 2307211 , commit 63651e1 (February 24, 2016), commit 87892f6 , commit 83837ec (February 21, 2016) and commit 1b47ad1 , commit d2b11ec ( February 17, 2016) Felipe GonΓ§alves Assis ( asiz ) .
(merger of Junio ​​C Hamano - gitster - in commit 4ce064d , February 26, 2016)

merge-recursive : option to disable renames

A recursive strategy includes defining a default rename.
Add a strategy parameter to disable rename detection even for precise rename .

man git-merge will include:

 no-renames 

Disable rename detection.
See git diff --no-rename .

(Note, as shown in commit 1b47ad1 , the find-renames merge strategy, following the git diff interface, makes the rename-threshold redundant option starting with git 2.8)

+1
Feb 27 '16 at 16:59
source share



All Articles