How to fix CONFLICT (modify/delete): file.txt deleted in branch and modified in HEAD in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 297 views

This Git merge conflict occurs when a file was deleted in one branch but modified in your current branch (HEAD). Git cannot automatically decide whether to keep your changes or accept the deletion, requiring manual resolution.

Quick fix

Fixes CONFLICT (modify/delete): file.txt deleted in branch and modified in HEAD

git status
  1. Check the conflict status
  2. Review the modifications
  3. Option A: Keep the modified file
  4. Option B: Accept the deletion
git โ€” error
git status
CONFLICT (modify/delete): file.txt deleted in branch and modified in HEAD

What this error means

When Git displays 'CONFLICT (modify/delete)', it means you are attempting to merge two branches with incompatible changes to the same file. In your current branch (HEAD), the file was edited and contains modifications. In the branch you're merging from, the same file was deleted entirely. Git cannot automatically resolve this because it doesn't know your intent. Should it keep your modified version of the file, or should it accept the deletion from the other branch? This is a decision only you can make, because it requires understanding why the file was deleted and whether your changes are still relevant. This type of conflict is common in team environments where one developer removes a file (perhaps as part of a refactor) while another developer continues to work on it. It can also happen when files are renamed or moved to a different location, as Git sometimes interprets a rename as a delete-and-create operation.

Typical symptoms

  • Merge or rebase operation stops with CONFLICT (modify/delete) message
  • git status shows the file under "Unmerged paths" with "deleted by them" or "deleted by us"
  • The file appears in your working directory but Git does not know what to do with it
  • Running git merge --continue or git commit fails until conflict is resolved
  • Pull requests or merge requests show merge conflicts that cannot be auto-resolved

Common causes

  1. One branch deleted a file while another branch modified it
  2. A file was renamed or moved in one branch and edited in another
  3. A refactoring effort removed files that were still being worked on in feature branches
  4. A file was moved to a different repository or split into multiple files
  5. Lack of communication between team members about file reorganization

How to fix "CONFLICT (modify/delete): file.txt deleted in branch and modified in HEAD"

1Check the conflict status

Run git status to see which files are in conflict and understand the situation:

bash
git status

Look for files listed under 'Unmerged paths'. The output will indicate whether the file was 'deleted by them' (deleted in the branch you're merging) or 'deleted by us' (deleted in your current branch).

2Review the modifications

Before deciding whether to keep or delete the file, review what changes were made. You can see the modifications using:

bash
git diff HEAD -- path/to/file.txt

Or to see the file's history and understand why it might have been deleted:

bash
git log --oneline -- path/to/file.txt
3Option A: Keep the modified file

If you want to keep your modifications and restore the file, stage it with git add:

bash
git add path/to/file.txt

This tells Git to include the file in the merge result with your modifications intact.

4Option B: Accept the deletion

If the file should be deleted (perhaps the modifications are no longer needed), remove it with git rm:

bash
git rm path/to/file.txt

This tells Git to accept the deletion and not include the file in the merge result.

5Complete the merge

After resolving all conflicts, complete the merge by committing:

bash
git commit

Or if you're in the middle of a merge:

bash
git merge --continue

Git will open your editor for a commit message. The default merge commit message usually works fine.

6Use git mergetool for interactive resolution

For a more interactive approach, you can use git mergetool:

bash
git mergetool

This will prompt you for each conflicted file. For modify/delete conflicts, it will ask whether you want to keep the modified version (press 'm') or delete the file (press 'd').

Advanced notes

When a file is renamed or moved in one branch and modified in another, Git may report this as a modify/delete conflict because it doesn't always detect renames perfectly. In these cases, you may need to manually apply your modifications to the file at its new location.

To check if a file was renamed rather than deleted, look at the commit that removed it:

bash
git log --diff-filter=D --summary | grep -A 5 'file.txt'
git log --diff-filter=R --summary  # Shows renames

If you frequently encounter modify/delete conflicts, consider these preventive measures:

1. Pull frequently: Regular pulls from the main branch help catch file reorganizations early
2. Communicate refactoring: When renaming or deleting files, notify team members who might be working on them
3. Use feature flags: Instead of deleting code, consider using feature flags to disable it temporarily
4. Smaller, focused branches: Keep feature branches small and merge them quickly to reduce divergence

If you need to abort the merge and start over:

bash
git merge --abort

Frequently asked questions

What does "CONFLICT (modify/delete): file.txt deleted in branch and modified in H" mean?
When Git displays 'CONFLICT (modify/delete)', it means you are attempting to merge two branches with incompatible changes to the same file. In your current branch (HEAD), the file was edited and contains modifications. In the branch you're merging from, the same file was deleted entirely.
How do I fix "CONFLICT (modify/delete): file.txt deleted in branch and modified in H"?
This Git merge conflict occurs when a file was deleted in one branch but modified in your current branch (HEAD). Git cannot automatically decide whether to keep your changes or accept the deletion, requiring manual resolution.
What causes "CONFLICT (modify/delete): file.txt deleted in branch and modified in H"?
One branch deleted a file while another branch modified it A file was renamed or moved in one branch and edited in another A refactoring effort removed files that were still being worked on in feature branches
Is the "CONFLICT (modify/delete): file.txt deleted in branch and modified in H" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading