Disable Git Rename Detection












8
















  1. I have a file, foo.txt

  2. Create and checkout branch 'branch_A'


  3. git mv foo.txt bar.txt followed by git add -A then git commit -m "renamed foo.txt"

  4. Checkout master, git checkout master

  5. remove foo.txt and commit.

  6. Now merge branch_A, git merge branch_A


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



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


This makes sense and is what I'd expect. However, I'd 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'd expect git to detect that foo.txt was deleted and simply add bar.txt. No conflict.



I've tried using -X rename-threshold, but it has not worked for me. I've tried thresholds 0 and 120 (a number above 100). What am I missing?



Thanks!



P.S. I'm also getting error: refusing to lose untracked file at... errors. What does this mean?










share|improve this question


















  • 1





    error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

    – Chris Frederick
    May 16 '11 at 4:57








  • 1





    With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

    – VonC
    Feb 27 '16 at 16:59






  • 1





    With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

    – VonC
    Jun 3 '18 at 21:31
















8
















  1. I have a file, foo.txt

  2. Create and checkout branch 'branch_A'


  3. git mv foo.txt bar.txt followed by git add -A then git commit -m "renamed foo.txt"

  4. Checkout master, git checkout master

  5. remove foo.txt and commit.

  6. Now merge branch_A, git merge branch_A


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



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


This makes sense and is what I'd expect. However, I'd 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'd expect git to detect that foo.txt was deleted and simply add bar.txt. No conflict.



I've tried using -X rename-threshold, but it has not worked for me. I've tried thresholds 0 and 120 (a number above 100). What am I missing?



Thanks!



P.S. I'm also getting error: refusing to lose untracked file at... errors. What does this mean?










share|improve this question


















  • 1





    error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

    – Chris Frederick
    May 16 '11 at 4:57








  • 1





    With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

    – VonC
    Feb 27 '16 at 16:59






  • 1





    With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

    – VonC
    Jun 3 '18 at 21:31














8












8








8


4







  1. I have a file, foo.txt

  2. Create and checkout branch 'branch_A'


  3. git mv foo.txt bar.txt followed by git add -A then git commit -m "renamed foo.txt"

  4. Checkout master, git checkout master

  5. remove foo.txt and commit.

  6. Now merge branch_A, git merge branch_A


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



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


This makes sense and is what I'd expect. However, I'd 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'd expect git to detect that foo.txt was deleted and simply add bar.txt. No conflict.



I've tried using -X rename-threshold, but it has not worked for me. I've tried thresholds 0 and 120 (a number above 100). What am I missing?



Thanks!



P.S. I'm also getting error: refusing to lose untracked file at... errors. What does this mean?










share|improve this question















  1. I have a file, foo.txt

  2. Create and checkout branch 'branch_A'


  3. git mv foo.txt bar.txt followed by git add -A then git commit -m "renamed foo.txt"

  4. Checkout master, git checkout master

  5. remove foo.txt and commit.

  6. Now merge branch_A, git merge branch_A


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



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


This makes sense and is what I'd expect. However, I'd 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'd expect git to detect that foo.txt was deleted and simply add bar.txt. No conflict.



I've tried using -X rename-threshold, but it has not worked for me. I've tried thresholds 0 and 120 (a number above 100). What am I missing?



Thanks!



P.S. I'm also getting error: refusing to lose untracked file at... errors. What does this mean?







git merge rename






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 16 '11 at 4:47









Ken HirakawaKen Hirakawa

2,87183246




2,87183246








  • 1





    error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

    – Chris Frederick
    May 16 '11 at 4:57








  • 1





    With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

    – VonC
    Feb 27 '16 at 16:59






  • 1





    With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

    – VonC
    Jun 3 '18 at 21:31














  • 1





    error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

    – Chris Frederick
    May 16 '11 at 4:57








  • 1





    With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

    – VonC
    Feb 27 '16 at 16:59






  • 1





    With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

    – VonC
    Jun 3 '18 at 21:31








1




1





error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

– Chris Frederick
May 16 '11 at 4:57







error: refusing to lose untracked file at... could be the result of merging bar.txt, which was tracked in branch_A but untracked in master, assuming that it exists in your working directory

– Chris Frederick
May 16 '11 at 4:57






1




1





With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

– VonC
Feb 27 '16 at 16:59





With git 2.8 (March 2016), you will have the option of doing a git merge --no-renames. See my answer below

– VonC
Feb 27 '16 at 16:59




1




1





With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

– VonC
Jun 3 '18 at 21:31





With Git 2.18 (Q2 2018), you have the option of git config merge.renames false. See my updated answer below.

– VonC
Jun 3 '18 at 21:31












2 Answers
2






active

oldest

votes


















7














Can you try with:



git merge -s resolve branch_A


Also, have you tried looking at similar questions here:



git rename/delete confusion



git divergent renaming






share|improve this answer





















  • 1





    This really needs more explanation

    – Liam
    Nov 21 '18 at 16:40



















5














With git 2.8 (March 2016), you will have another option (as an option to the recursive merge strategy)



git merge -Srecursive -Xno-renames


See commit 44c74ec, commit 2307211, commit 63651e1 (24 Feb 2016), commit 2307211, commit 63651e1 (24 Feb 2016), commit 87892f6, commit 83837ec (21 Feb 2016), and commit 1b47ad1, commit d2b11ec (17 Feb 2016) by Felipe Gonçalves Assis (asiz).
(Merged by Junio C Hamano -- gitster -- in commit 4ce064d, 26 Feb 2016)





merge-recursive: option to disable renames



The recursive strategy turns on rename detection by default.
Add a strategy option to disable rename detection even for exact renames.




The man git-merge will include:




no-renames


Turn off rename detection.

See git diff --no-rename.




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





You have an additional setting with Git 2.18 (Q2 2018): with the merge.renames configuration set to false, the recursive merge strategy can be told not to spend cycles trying to find renamed paths and merge them accordingly.



See commit 6f10a09, commit 85b4603, commit a7152e9 (02 May 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 6e2ba77, 30 May 2018)




merge: add merge.renames config setting



Add the ability to control rename detection for merge via a config setting.

This setting behaves the same and defaults to the value of diff.renames but only applies to merge.







share|improve this answer


























  • was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

    – ThorSummoner
    Jun 24 '16 at 22:10






  • 1





    @ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

    – VonC
    Jun 24 '16 at 22:23











  • @VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

    – chrisinmtown
    May 10 '17 at 12:59











  • @chrisinmtown Thank you. I have edited the answer accordingly.

    – VonC
    May 10 '17 at 13:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6013261%2fdisable-git-rename-detection%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









7














Can you try with:



git merge -s resolve branch_A


Also, have you tried looking at similar questions here:



git rename/delete confusion



git divergent renaming






share|improve this answer





















  • 1





    This really needs more explanation

    – Liam
    Nov 21 '18 at 16:40
















7














Can you try with:



git merge -s resolve branch_A


Also, have you tried looking at similar questions here:



git rename/delete confusion



git divergent renaming






share|improve this answer





















  • 1





    This really needs more explanation

    – Liam
    Nov 21 '18 at 16:40














7












7








7







Can you try with:



git merge -s resolve branch_A


Also, have you tried looking at similar questions here:



git rename/delete confusion



git divergent renaming






share|improve this answer















Can you try with:



git merge -s resolve branch_A


Also, have you tried looking at similar questions here:



git rename/delete confusion



git divergent renaming







share|improve this answer














share|improve this answer



share|improve this answer








edited May 23 '17 at 12:18









Community

11




11










answered May 16 '11 at 5:27









manojldsmanojlds

216k46379366




216k46379366








  • 1





    This really needs more explanation

    – Liam
    Nov 21 '18 at 16:40














  • 1





    This really needs more explanation

    – Liam
    Nov 21 '18 at 16:40








1




1





This really needs more explanation

– Liam
Nov 21 '18 at 16:40





This really needs more explanation

– Liam
Nov 21 '18 at 16:40













5














With git 2.8 (March 2016), you will have another option (as an option to the recursive merge strategy)



git merge -Srecursive -Xno-renames


See commit 44c74ec, commit 2307211, commit 63651e1 (24 Feb 2016), commit 2307211, commit 63651e1 (24 Feb 2016), commit 87892f6, commit 83837ec (21 Feb 2016), and commit 1b47ad1, commit d2b11ec (17 Feb 2016) by Felipe Gonçalves Assis (asiz).
(Merged by Junio C Hamano -- gitster -- in commit 4ce064d, 26 Feb 2016)





merge-recursive: option to disable renames



The recursive strategy turns on rename detection by default.
Add a strategy option to disable rename detection even for exact renames.




The man git-merge will include:




no-renames


Turn off rename detection.

See git diff --no-rename.




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





You have an additional setting with Git 2.18 (Q2 2018): with the merge.renames configuration set to false, the recursive merge strategy can be told not to spend cycles trying to find renamed paths and merge them accordingly.



See commit 6f10a09, commit 85b4603, commit a7152e9 (02 May 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 6e2ba77, 30 May 2018)




merge: add merge.renames config setting



Add the ability to control rename detection for merge via a config setting.

This setting behaves the same and defaults to the value of diff.renames but only applies to merge.







share|improve this answer


























  • was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

    – ThorSummoner
    Jun 24 '16 at 22:10






  • 1





    @ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

    – VonC
    Jun 24 '16 at 22:23











  • @VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

    – chrisinmtown
    May 10 '17 at 12:59











  • @chrisinmtown Thank you. I have edited the answer accordingly.

    – VonC
    May 10 '17 at 13:36
















5














With git 2.8 (March 2016), you will have another option (as an option to the recursive merge strategy)



git merge -Srecursive -Xno-renames


See commit 44c74ec, commit 2307211, commit 63651e1 (24 Feb 2016), commit 2307211, commit 63651e1 (24 Feb 2016), commit 87892f6, commit 83837ec (21 Feb 2016), and commit 1b47ad1, commit d2b11ec (17 Feb 2016) by Felipe Gonçalves Assis (asiz).
(Merged by Junio C Hamano -- gitster -- in commit 4ce064d, 26 Feb 2016)





merge-recursive: option to disable renames



The recursive strategy turns on rename detection by default.
Add a strategy option to disable rename detection even for exact renames.




The man git-merge will include:




no-renames


Turn off rename detection.

See git diff --no-rename.




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





You have an additional setting with Git 2.18 (Q2 2018): with the merge.renames configuration set to false, the recursive merge strategy can be told not to spend cycles trying to find renamed paths and merge them accordingly.



See commit 6f10a09, commit 85b4603, commit a7152e9 (02 May 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 6e2ba77, 30 May 2018)




merge: add merge.renames config setting



Add the ability to control rename detection for merge via a config setting.

This setting behaves the same and defaults to the value of diff.renames but only applies to merge.







share|improve this answer


























  • was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

    – ThorSummoner
    Jun 24 '16 at 22:10






  • 1





    @ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

    – VonC
    Jun 24 '16 at 22:23











  • @VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

    – chrisinmtown
    May 10 '17 at 12:59











  • @chrisinmtown Thank you. I have edited the answer accordingly.

    – VonC
    May 10 '17 at 13:36














5












5








5







With git 2.8 (March 2016), you will have another option (as an option to the recursive merge strategy)



git merge -Srecursive -Xno-renames


See commit 44c74ec, commit 2307211, commit 63651e1 (24 Feb 2016), commit 2307211, commit 63651e1 (24 Feb 2016), commit 87892f6, commit 83837ec (21 Feb 2016), and commit 1b47ad1, commit d2b11ec (17 Feb 2016) by Felipe Gonçalves Assis (asiz).
(Merged by Junio C Hamano -- gitster -- in commit 4ce064d, 26 Feb 2016)





merge-recursive: option to disable renames



The recursive strategy turns on rename detection by default.
Add a strategy option to disable rename detection even for exact renames.




The man git-merge will include:




no-renames


Turn off rename detection.

See git diff --no-rename.




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





You have an additional setting with Git 2.18 (Q2 2018): with the merge.renames configuration set to false, the recursive merge strategy can be told not to spend cycles trying to find renamed paths and merge them accordingly.



See commit 6f10a09, commit 85b4603, commit a7152e9 (02 May 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 6e2ba77, 30 May 2018)




merge: add merge.renames config setting



Add the ability to control rename detection for merge via a config setting.

This setting behaves the same and defaults to the value of diff.renames but only applies to merge.







share|improve this answer















With git 2.8 (March 2016), you will have another option (as an option to the recursive merge strategy)



git merge -Srecursive -Xno-renames


See commit 44c74ec, commit 2307211, commit 63651e1 (24 Feb 2016), commit 2307211, commit 63651e1 (24 Feb 2016), commit 87892f6, commit 83837ec (21 Feb 2016), and commit 1b47ad1, commit d2b11ec (17 Feb 2016) by Felipe Gonçalves Assis (asiz).
(Merged by Junio C Hamano -- gitster -- in commit 4ce064d, 26 Feb 2016)





merge-recursive: option to disable renames



The recursive strategy turns on rename detection by default.
Add a strategy option to disable rename detection even for exact renames.




The man git-merge will include:




no-renames


Turn off rename detection.

See git diff --no-rename.




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





You have an additional setting with Git 2.18 (Q2 2018): with the merge.renames configuration set to false, the recursive merge strategy can be told not to spend cycles trying to find renamed paths and merge them accordingly.



See commit 6f10a09, commit 85b4603, commit a7152e9 (02 May 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 6e2ba77, 30 May 2018)




merge: add merge.renames config setting



Add the ability to control rename detection for merge via a config setting.

This setting behaves the same and defaults to the value of diff.renames but only applies to merge.








share|improve this answer














share|improve this answer



share|improve this answer








edited Jun 3 '18 at 21:30

























answered Feb 27 '16 at 16:59









VonCVonC

847k29626913250




847k29626913250













  • was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

    – ThorSummoner
    Jun 24 '16 at 22:10






  • 1





    @ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

    – VonC
    Jun 24 '16 at 22:23











  • @VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

    – chrisinmtown
    May 10 '17 at 12:59











  • @chrisinmtown Thank you. I have edited the answer accordingly.

    – VonC
    May 10 '17 at 13:36



















  • was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

    – ThorSummoner
    Jun 24 '16 at 22:10






  • 1





    @ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

    – VonC
    Jun 24 '16 at 22:23











  • @VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

    – chrisinmtown
    May 10 '17 at 12:59











  • @chrisinmtown Thank you. I have edited the answer accordingly.

    – VonC
    May 10 '17 at 13:36

















was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

– ThorSummoner
Jun 24 '16 at 22:10





was this removed in 2.9? The git maintainers ppa of stable releases does not have this flag AFAICT.

– ThorSummoner
Jun 24 '16 at 22:10




1




1





@ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

– VonC
Jun 24 '16 at 22:23





@ThorSummoner I agree. It is actually an option to a merge strategy. I have edited the answer.

– VonC
Jun 24 '16 at 22:23













@VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

– chrisinmtown
May 10 '17 at 12:59





@VonC: may I offer 2 tiny edits: add hyphen in git-merge; drop double-hyphen before no-renames. Should say: "The man git-merge will include: no-renames"

– chrisinmtown
May 10 '17 at 12:59













@chrisinmtown Thank you. I have edited the answer accordingly.

– VonC
May 10 '17 at 13:36





@chrisinmtown Thank you. I have edited the answer accordingly.

– VonC
May 10 '17 at 13:36


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6013261%2fdisable-git-rename-detection%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini