How to fix CONFLICT (add/add): Merge conflict in file.txt in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025· 230 views

An add/add conflict occurs when two branches independently add a file with the same name. Git cannot automatically decide which version to keep, requiring manual resolution to choose one version, combine both, or rename one of the files.

Quick fix

Fixes CONFLICT (add/add): Merge conflict in file.txt

git status
  1. Identify the conflicting files
  2. View the differences between versions
  3. Choose a resolution strategy
  4. Complete the merge or rebase
git — error
git status
CONFLICT (add/add): Merge conflict in file.txt

What this error means

The "CONFLICT (add/add)" error indicates that Git encountered a merge conflict because both branches being merged have added a new file with the exact same path and filename. Unlike modify/modify conflicts where both branches edited an existing file, add/add conflicts happen when the file did not exist in the common ancestor commit but was created independently in both branches. This situation commonly arises in team development when multiple developers create the same configuration file, test file, or utility module without coordination. Git cannot automatically resolve this because there is no common base to compare against—both files are entirely new additions with potentially completely different content. The conflict must be resolved manually by deciding which version to keep, merging the contents of both files, or renaming one of the files to preserve both.

Typical symptoms

  • Git merge or rebase fails with "CONFLICT (add/add)" message
  • The conflicting file shows with "both added" status in git status
  • The file contains conflict markers (<<<<<<, =======, >>>>>>>) when opened
  • git diff shows the file in the "Unmerged paths" section
  • Pull requests cannot be merged due to conflicting new files

Common causes

  1. Two developers independently created the same file in separate branches
  2. A configuration or boilerplate file was added in multiple feature branches
  3. Rebasing a branch that adds a file onto a branch where the same file was already added
  4. Cherry-picking a commit that adds a file already present in the target branch
  5. File mode differences (e.g., 644 vs 755 permissions) between otherwise identical files

How to fix "CONFLICT (add/add): Merge conflict in file.txt"

1Identify the conflicting files

First, check which files have add/add conflicts:

bash
git status

Look for files listed under "Unmerged paths" with "both added" status. You can also see the specific conflict type with:

bash
git diff --name-only --diff-filter=U
2View the differences between versions

Compare the two versions to understand what each branch added:

bash
git diff

This shows the conflict markers and both versions. To see each version separately:

bash
# View version from current branch (ours)
git show :2:path/to/file.txt

# View version from incoming branch (theirs)
git show :3:path/to/file.txt
3Choose a resolution strategy

Option A: Keep one version entirely

To keep your current branch's version:

bash
git checkout --ours path/to/file.txt
git add path/to/file.txt

To keep the incoming branch's version:

bash
git checkout --theirs path/to/file.txt
git add path/to/file.txt

Option B: Manually merge the content

Open the file in your editor, remove the conflict markers (<<<<<<<, =======, >>>>>>>), and combine the content as needed. Then stage the resolved file:

bash
git add path/to/file.txt

Option C: Keep both files with different names

If you need to preserve both versions:

bash
# Extract the other version to a new filename
git show :3:file.txt > file-from-other-branch.txt
# Keep your version
git checkout --ours file.txt
# Stage both files
git add file.txt file-from-other-branch.txt
4Complete the merge or rebase

After resolving all conflicts, complete the operation:

For merge:

bash
git commit -m "Resolve add/add conflict in file.txt"

For rebase:

bash
git rebase --continue

If you want to abort and start over:

bash
# Abort merge
git merge --abort

# Abort rebase
git rebase --abort

Advanced notes

### File Mode Conflicts

Sometimes an add/add conflict occurs even when file contents are identical, due to different file permissions. On Unix systems, files might be added with mode 644 (rw-r--r--) in one branch and 755 (rwxr-xr-x) in another. Use git ls-files -s to check file modes and git update-index --chmod=+x file to set executable permission.

### Preventing Add/Add Conflicts

To avoid these conflicts in team environments:
- Communicate when adding new files to shared paths (configs, utilities)
- Use branch naming conventions and keep branches short-lived
- Regularly rebase feature branches on the main branch to detect conflicts early
- Consider using tools like git hooks to notify when certain file patterns are added

### Binary Files

For binary files (images, compiled assets), Git cannot show conflict markers. You must choose one version using git checkout --ours or --theirs. If you need to combine binary files, export both versions and use appropriate tools (image editors, etc.) before staging the result.

Frequently asked questions

What does "CONFLICT (add/add): Merge conflict in file.txt" mean?
The "CONFLICT (add/add)" error indicates that Git encountered a merge conflict because both branches being merged have added a new file with the exact same path and filename. Unlike modify/modify conflicts where both branches edited an existing file, add/add conflicts happen when the file did not exist in the common ancestor commit but was created independently in both branches. This situation commonly arises in team development when multiple developers create the same configuration file, test file, or utility module without coordination.
How do I fix "CONFLICT (add/add): Merge conflict in file.txt"?
An add/add conflict occurs when two branches independently add a file with the same name. Git cannot automatically decide which version to keep, requiring manual resolution to choose one version, combine both, or rename one of the files.
What causes "CONFLICT (add/add): Merge conflict in file.txt"?
Two developers independently created the same file in separate branches A configuration or boilerplate file was added in multiple feature branches Rebasing a branch that adds a file onto a branch where the same file was already added
Is the "CONFLICT (add/add): Merge conflict in file.txt" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading