How to Fix Git CONFLICT (modify/delete)
When git merge stops with CONFLICT (modify/delete), one branch deleted a file while the other branch modified it. To resolve it, decide whether to keep the file (git add) or delete it (git rm), then finish the merge with git commit. The conflict is then cleared.
This message appears when you merge a branch that rewrote a page into a branch that deleted the same page, or when you git rebase the branch that rewrote the page onto the branch that deleted it. I reproduced it on purpose in a test environment and confirmed the message it shows and that it disappears after the fix.
The test environment was Ubuntu 24.04, Git 2.43.0, and bash 5.2. I ran the commands with LANG=C so the messages would be in English. I used only repositories I created locally. I did not test conflicts that come from remote operations (conflicts from git pull), the display in git mergetool or editor and GUI tools, or Windows and macOS.
- 1. Stopping when deletion and modification collide
- 2. Use git status to see which side deleted the file
- 3. Check what the other side changed before deleting
- 4. Fix 1: keep the rewritten content with git add
- 5. Fix 2: delete the file with git rm
- 6. git checkout –ours does not work here
- 7. With git rebase, HEAD is the main you are rebasing onto
Stopping when deletion and modification collide
On the main branch I deleted news.html. On the update-news branch I rewrote the text of the same news.html.
$ git log --oneline --all --stat
fc07865 お知らせのページを消す
news.html | 2 --
1 file changed, 2 deletions(-)
0fda084 お知らせを書き直す
news.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
b976f85 最初のコミット
index.html | 1 +
news.html | 2 ++
2 files changed, 3 insertions(+)
When I merged update-news into main, the merge stopped with the following message. The exit code was 1.
$ git merge update-news
CONFLICT (modify/delete): news.html deleted in HEAD and modified in update-news. Version update-news of news.html left in tree.
Automatic merge failed; fix conflicts and then commit the result.
deleted in HEAD means "deleted on the branch you are currently on (main)". modified in update-news means "rewritten on update-news". As the message Version update-news of news.html left in tree. says, the version of news.html from the rewriting side was left in the working folder.
$ cat news.html
<h1>お知らせ</h1>
<p>12月は毎週土曜に更新します</p>
Git stops without choosing either "delete" or "rewrite" and leaves the decision to you. Unlike an ordinary conflict, the file did not contain conflict markers such as <<<<<<<.

Use git status to see which side deleted the file
git status showed deleted by us under Unmerged paths. "us" refers to 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: news.html
no changes added to commit (use "git add" and/or "git commit -a")
In the short format (git status --short) the status is DU. In the table in the official git status reference, DU means "unmerged, deleted by us", and the reverse, UD, means "unmerged, deleted by them".
$ git status --short
DU news.html
Conversely, when I was on update-news, which rewrote the file, and merged in main, which deleted it, the HEAD and other side swapped in the message, and the status became deleted by them. The file left in the working folder was again the rewritten version from the side that rewrote it (here, HEAD).
$ git merge main
CONFLICT (modify/delete): news.html deleted in main and modified in HEAD. Version HEAD of news.html left in tree.
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch update-news
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 them: news.html
no changes added to commit (use "git add" and/or "git commit -a")
Check what the other side changed before deleting
Before deciding whether to keep or delete the file, check what the side that modified it changed. While the conflict is active, git ls-files --stage lists the same file several times, each with a stage number.
$ git ls-files --stage news.html
100644 f885a57669fca24ef11e414030ab06ebe018778c 1 news.html
100644 4a8eb34da990a3c20c2fc596d532b5087220d9f8 3 news.html
According to the official revision syntax reference, during a merge stage 1 is the common ancestor, stage 2 is the branch you are on, and stage 3 is the branch being merged in. Because I deleted the file on main, there is no stage 2 here. Comparing stage 1 with stage 3 showed only the line that was rewritten on update-news.
$ git diff :1:news.html :3:news.html
diff --git a/news.html b/news.html
index f885a57..4a8eb34 100644
--- a/news.html
+++ b/news.html
@@ -1,2 +1,2 @@
<h1>お知らせ</h1>
-<p>12月の更新はお休みです</p>
+<p>12月は毎週土曜に更新します</p>
In the deleted by them case, the stages that remain are 1 and 2, so use git diff :1:news.html :2:news.html to check the lines you rewrote.
Fix 1: keep the rewritten content with git add
To keep the file, run git add and then commit. git status changed to All conflicts fixed but you are still merging., and news.html appeared as a new file in the changes to be committed.
$ git add news.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: news.html
$ git commit --no-edit
[main f59953b] Merge branch 'update-news'
$ git status
On branch main
nothing to commit, working tree clean
--no-edit is an option that commits with the message Git prepared, without opening an editor. After the commit, git diff --name-only --diff-filter=U, which lists conflicted files, printed nothing, and news.html remained with the rewritten content.
$ git diff --name-only --diff-filter=U
$ git ls-files
index.html
news.html
$ cat news.html
<h1>お知らせ</h1>
<p>12月は毎週土曜に更新します</p>
Fix 2: delete the file with git rm
To delete the file, run git rm and then commit. When I started again from the same state, news.html was gone from both the folder and the repository.
$ git rm news.html
rm 'news.html'
$ git status
On branch main
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
$ git commit --no-edit
[main 441e752] Merge branch 'update-news'
$ git status
On branch main
nothing to commit, working tree clean
$ ls
index.html
When I was on update-news and the status was deleted by them, running git rm news.html and git commit --no-edit finished the same way, and the result was working tree clean.
If you choose git rm, the content you rewrote on the other branch is deleted along with the file. If you want to move the rewritten text to another file, copy the content first, for example with cat news.html, before running git rm.
git checkout –ours does not work here
In an ordinary conflict, you can take one side's entire content with git checkout --ours or --theirs, as described in the official git checkout reference. In a modify/delete conflict, specifying the side that deleted the file produced this error.
$ git checkout --ours news.html
error: path 'news.html' does not have our version
When the status was deleted by them, specifying --theirs gave error: path 'news.html' does not have their version. The side that deleted the file has no content to take, so use git rm instead.
Also, running git commit without choosing either side stopped the process.
$ git commit --no-edit
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
U news.html
If you want to abandon the merge itself, git merge --abort returns to the state before the merge. In my test, this returned me to the main state without news.html, and the status was working tree clean.
With git rebase, HEAD is the main you are rebasing onto
Running git rebase of update-news onto main stopped with the same CONFLICT (modify/delete).
$ git rebase main
Rebasing (1/1)CONFLICT (modify/delete): news.html deleted in HEAD and modified in 0fda084 (お知らせを書き直す). Version 0fda084 (お知らせを書き直す) of news.html left in tree.
error: could not apply 0fda084... お知らせを書き直す
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 0fda084... お知らせを書き直す
I was working on update-news, but the message said deleted in HEAD, and git status said deleted by us. During a rebase, your commits are replayed one at a time on top of the branch you are rebasing onto (main), so HEAD ("us") refers to main. The official git rebase reference also notes that during a rebase, ours and theirs are swapped.
To keep the rewritten content, run git add as in a merge, then run git rebase --continue instead of git commit. The rebase finished and the status became working tree clean.
$ git add news.html
$ git rebase --continue
[detached HEAD 1a16d99] お知らせを書き直す
1 file changed, 2 insertions(+)
create mode 100644 news.html
Successfully rebased and updated refs/heads/update-news.
$ git status
On branch update-news
nothing to commit, working tree clean
For the ordinary conflict, where the file contains conflict markers, see the separate article "How to resolve Git merge conflicts."





