Disable Git Rename Detection
- I have a file,
foo.txt
- Create and checkout branch 'branch_A'
git mv foo.txt bar.txt
followed bygit add -A
thengit commit -m "renamed foo.txt"
- Checkout master,
git checkout master
- remove foo.txt and commit.
- 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
add a comment |
- I have a file,
foo.txt
- Create and checkout branch 'branch_A'
git mv foo.txt bar.txt
followed bygit add -A
thengit commit -m "renamed foo.txt"
- Checkout master,
git checkout master
- remove foo.txt and commit.
- 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
1
error: refusing to lose untracked file at...
could be the result of mergingbar.txt
, which was tracked inbranch_A
but untracked inmaster
, 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 agit 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 ofgit config merge.renames false
. See my updated answer below.
– VonC
Jun 3 '18 at 21:31
add a comment |
- I have a file,
foo.txt
- Create and checkout branch 'branch_A'
git mv foo.txt bar.txt
followed bygit add -A
thengit commit -m "renamed foo.txt"
- Checkout master,
git checkout master
- remove foo.txt and commit.
- 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
- I have a file,
foo.txt
- Create and checkout branch 'branch_A'
git mv foo.txt bar.txt
followed bygit add -A
thengit commit -m "renamed foo.txt"
- Checkout master,
git checkout master
- remove foo.txt and commit.
- 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
git merge rename
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 mergingbar.txt
, which was tracked inbranch_A
but untracked inmaster
, 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 agit 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 ofgit config merge.renames false
. See my updated answer below.
– VonC
Jun 3 '18 at 21:31
add a comment |
1
error: refusing to lose untracked file at...
could be the result of mergingbar.txt
, which was tracked inbranch_A
but untracked inmaster
, 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 agit 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 ofgit 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
add a comment |
2 Answers
2
active
oldest
votes
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
1
This really needs more explanation
– Liam
Nov 21 '18 at 16:40
add a comment |
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.
Seegit 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
: addmerge.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 ofdiff.renames
but only applies to merge.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
1
This really needs more explanation
– Liam
Nov 21 '18 at 16:40
add a comment |
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
1
This really needs more explanation
– Liam
Nov 21 '18 at 16:40
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Seegit 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
: addmerge.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 ofdiff.renames
but only applies to merge.
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
add a comment |
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.
Seegit 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
: addmerge.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 ofdiff.renames
but only applies to merge.
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
add a comment |
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.
Seegit 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
: addmerge.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 ofdiff.renames
but only applies to merge.
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.
Seegit 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
: addmerge.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 ofdiff.renames
but only applies to merge.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
error: refusing to lose untracked file at...
could be the result of mergingbar.txt
, which was tracked inbranch_A
but untracked inmaster
, 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