Fixing Git CONFLICT (rename/delete)
git merge stops with CONFLICT (rename/delete) when one branch renamed a file and the other branch deleted it. To keep the file under its new name, run git add; to delete it, run git rm. Then finish the merge with git commit, and the conflict is resolved.
This message appears when you merge a branch that reorganized page file names into another branch that deleted the same page, or when you git rebase the branch that renamed the file on top of the branch that deleted it. I reproduced it on purpose in a test environment and checked the output, and confirmed that it disappears after the fix.
The test environment was Ubuntu 24.04, Git 2.43.0, and bash 5.2. I ran everything with LANG=C to match the English messages. I used only repositories I created locally. I did not test conflicts that come from remote operations (such as a conflict during git pull), display in git mergetool or editor and GUI tools, or Windows and macOS.
- 1. The conflict occurs when a rename meets a delete
- 2. git status shows the new name
- 3. Fix 1: keep the new name with git add
- 4. Fix 2: delete the file with git rm
- 5. Merging from the renamed side shows deleted by them
- 6. When the content also changed along with the name
- 7. When the content is rewritten heavily, the merge completes without a conflict
- 8. With git rebase, the renaming side is shown by commit
The conflict occurs when a rename meets a delete
On the main branch I deleted about.html. On the rename-page branch I used git mv to rename about.html to profile.html.
$ git log --oneline --all --stat
6024ad0 about.html を消す
about.html | 5 -----
1 file changed, 5 deletions(-)
1d0e66a about.html を profile.html に名前を変える
about.html => profile.html | 0
1 file changed, 0 insertions(+), 0 deletions(-)
3553433 最初のコミット
about.html | 5 +++++
index.html | 1 +
2 files changed, 6 insertions(+)
When I merged rename-page into main, the merge stopped with this message. The exit code was 1.
$ git merge rename-page
CONFLICT (rename/delete): about.html renamed to profile.html in rename-page, but deleted in HEAD.
Automatic merge failed; fix conflicts and then commit the result.
about.html renamed to profile.html in rename-page means that about.html was renamed to profile.html in rename-page. but deleted in HEAD means that the current branch (main) deleted it.
In the working folder, the new file profile.html was present. The old name about.html was gone. The file contained no conflict markers such as <<<<<<<.
$ ls
index.html
profile.html
$ cat profile.html
<h1>このブログについて</h1>
<p>猫と暮らす毎日を書いています</p>
<p>写真は自分で撮っています</p>
<p>コメントは承認してから表示します</p>
<p>連絡はお問い合わせページからどうぞ</p>

git status shows the new name
git status listed profile.html, the new name rather than the old one, under Unmerged paths as deleted by us. "Us" means the branch you are currently on.
$ git status
On branch main
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: profile.html
no changes added to commit (use "git add" and/or "git commit -a")
$ git status --short
DU profile.html
In the git status reference table, DU means "unmerged, deleted by us," and the reverse, UD, means "unmerged, deleted by them." The filename you pass to git add or git rm is the profile.html shown here.
git ls-files --stage showed that only profile.html was in conflict, with entries at stage numbers 1 and 3.
$ git ls-files --stage
100644 e54fb8dd943105190f8616b525110e6fb8853eec 0 index.html
100644 d42016180abc251cae587bc62c5aee210558db5b 1 profile.html
100644 d42016180abc251cae587bc62c5aee210558db5b 3 profile.html
According to the revision syntax reference, during a merge stage 1 is the common ancestor, stage 2 is the current branch, and stage 3 is the branch being merged. The content of about.html from the common ancestor appeared at stage 1 under the new name profile.html. There was no stage 2 entry because main deleted the file.
Fix 1: keep the new name with git add
If you decide to keep the renamed file, run git add and then commit.
$ git add profile.html
$ git status
On branch main
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
new file: profile.html
$ git commit --no-edit
[main e9590fd] Merge branch 'rename-page'
$ git status
On branch main
nothing to commit, working tree clean
--no-edit commits with the message Git generated, without opening an editor. After the commit, git diff --name-only --diff-filter=U, which lists conflicted files, printed nothing. The repository keeps profile.html under its new name, and about.html does not come back.
$ git diff --name-only --diff-filter=U
$ git ls-files
index.html
profile.html
Fix 2: delete the file with git rm
If you decide to delete the file, run git rm on the new name profile.html and then commit. I repeated the same starting state and this time both the old and new names were removed from the folder and the repository.
$ git rm profile.html
rm 'profile.html'
$ git commit --no-edit
[main 79c12a5] Merge branch 'rename-page'
$ git status
On branch main
nothing to commit, working tree clean
$ git ls-files
index.html
To cancel the merge entirely, run git merge --abort. In my test, this returned me to main as it was before the merge, with neither about.html nor profile.html present.
Merging from the renamed side shows deleted by them
When I was on rename-page and merged the deleting main branch, the message read renamed to profile.html in HEAD. The renaming side is shown as HEAD.
$ git merge main
CONFLICT (rename/delete): about.html renamed to profile.html in HEAD, but deleted in main.
Automatic merge failed; fix conflicts and then commit the result.
$ git status --short
UD profile.html
git status showed deleted by them: profile.html. In this case the file content existed only on my side, so git checkout --ours extracted the new-name profile.html. --theirs produced an error.
$ git checkout --theirs profile.html
error: path 'profile.html' does not have their version
$ git checkout --ours profile.html
Updated 1 path from the index
When I was on main and the status was deleted by us, the reverse happened: --ours gave error: path 'profile.html' does not have our version. The git checkout –ours and –theirs options extract one side's content, so they cannot be used to choose the deleting side. To delete the file in either case, run git rm profile.html using the new name. On rename-page, too, git rm followed by git commit --no-edit left the working tree clean.
When the content also changed along with the name
After I renamed the file on rename-page and then rewrote one line of profile.html, the merge produced two CONFLICT lines.
$ git merge rename-page
CONFLICT (rename/delete): about.html renamed to profile.html in rename-page, but deleted in HEAD.
CONFLICT (modify/delete): profile.html deleted in HEAD and modified in rename-page. Version rename-page of profile.html left in tree.
Automatic merge failed; fix conflicts and then commit the result.
Only one file, profile.html, was in conflict in this case as well, and git status --short showed DU profile.html. You can see the line rewritten on the renamed side by comparing the common ancestor (stage 1) with the other side (stage 3).
$ git diff :1:profile.html :3:profile.html
diff --git a/profile.html b/profile.html
index d420161..0e6118a 100644
--- a/profile.html
+++ b/profile.html
@@ -1,5 +1,5 @@
<h1>このブログについて</h1>
-<p>猫と暮らす毎日を書いています</p>
+<p>猫と暮らす毎日を、週に1回書いています</p>
<p>写真は自分で撮っています</p>
<p>コメントは承認してから表示します</p>
<p>連絡はお問い合わせページからどうぞ</p>
The fix was the same as when only the name had changed. From the same starting state, I tried both git add profile.html to keep the file and git rm profile.html to delete it. In both cases, git commit --no-edit was followed by working tree clean, and git diff --name-only --diff-filter=U printed nothing. The second line, modify/delete itself, is covered in a separate article, "Fixing Git CONFLICT (modify/delete)."
When the content is rewritten heavily, the merge completes without a conflict
When I changed the content of the file heavily after renaming it, no conflict occurred. I replaced the five lines of about.html with two completely different lines in profile.html, and Git treated it as "delete about.html, create a new profile.html" rather than as a rename.
$ git diff --stat -M HEAD~1 rename-page
about.html | 5 -----
profile.html | 2 ++
2 files changed, 2 insertions(+), 5 deletions(-)
$ git merge rename-page
Merge made by the 'ort' strategy.
profile.html | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 profile.html
According to the git merge reference, merge detects renames by default, and the similarity threshold for deciding that a change is a rename works the same way as –find-renames in git diff. The default similarity for treating a change as a rename is 50%.
If the change is not recognized as a rename, a page you deleted on main will come back under the new name. No conflict message appears, so after merging into the branch that deleted the file, check with git ls-files or similar that no unwanted files have been added.
With git rebase, the renaming side is shown by commit
When I ran git rebase to replay rename-page on top of main, it stopped with the same CONFLICT (rename/delete). Unlike merge, the renaming side is shown not by branch name but by the commit being replayed (1d0e66a).
$ git rebase main
Rebasing (1/1)CONFLICT (rename/delete): about.html renamed to profile.html in 1d0e66a (about.html を profile.html に名前を変える), but deleted in HEAD.
error: could not apply 1d0e66a... about.html を profile.html に名前を変える
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 1d0e66a... about.html を profile.html に名前を変える
Even though I was working on rename-page, the message said deleted in HEAD, and git status showed deleted by us: profile.html. This is because during rebase, ours and theirs are swapped (see the git rebase reference). The filename was again the new name profile.html. To keep the file under the new name, run git add profile.html and then git rebase --continue.
$ git add profile.html
$ git rebase --continue
[detached HEAD dd9310d] about.html を profile.html に名前を変える
1 file changed, 5 insertions(+)
create mode 100644 profile.html
Successfully rebased and updated refs/heads/rename-page.
$ git status
On branch rename-page
nothing to commit, working tree clean





