Git conflict "both deleted"
I don't understand why "both deleted" is the status for unlinked paths.
If a:
- OldStandard is the base
- NewStandard - last commit on outside line
- OldCustom is a fork from OldStandard that we are trying to merge into master
Why is there a conflict with some files marked as "both deleted"?
I understand the conflict for "both added" where one file is added to NewStandard and another version of the file is added to OldCustom.
But, for deletion, what is the problem if the file was deleted in NewStandard and also deleted in OldCustom? What's the equivalent state, no?
source to share
As pointed out in this answer (suggested in duplicate):
you can see "both deleted" when it branchA
has a commit git mv oldfile newstandard
and branchB
has a commit git mv oldfile newcustom
.
In this case, when trying to merge customBranch
with standardBranch
, it git
will report a conflict of three files:
both deleted: oldfile
added by them: newcustom
added by us: newstandard
As with any conflict, the final choice is in your hands:
git
just underlines the fact that maybe there could be a problem with the fact that newcustom
both newstandard
live together in your final version of the code, and maybe it could be due to the fact that both of them were created being a copy from oldfile
.
You can fix it manually:
- if the deletion
oldfile
is the expected result:git reset oldfile && git rm oldfile
, - If saving
newstandard
is the expected result, remove both:git reset newcustom && git rm newcustom
, - if some parts
newstandard
, andnewcustom
must be combined: edit them manually or use a tool tripartite association:meld newstandard newstandard newcustom
- etc...
source to share