How to fix CONFLICT (add/add): Merge conflict in file.txt in Git
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- Identify the conflicting files
- View the differences between versions
- Choose a resolution strategy
- Complete the merge or rebase
git statusCONFLICT (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
- 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
- Cherry-picking a commit that adds a file already present in the target branch
- File mode differences (e.g., 644 vs 755 permissions) between otherwise identical files
How to fix "CONFLICT (add/add): Merge conflict in file.txt"
First, check which files have add/add conflicts:
git statusLook for files listed under "Unmerged paths" with "both added" status. You can also see the specific conflict type with:
git diff --name-only --diff-filter=UCompare the two versions to understand what each branch added:
git diffThis shows the conflict markers and both versions. To see each version separately:
# 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.txtOption A: Keep one version entirely
To keep your current branch's version:
git checkout --ours path/to/file.txt
git add path/to/file.txtTo keep the incoming branch's version:
git checkout --theirs path/to/file.txt
git add path/to/file.txtOption 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:
git add path/to/file.txtOption C: Keep both files with different names
If you need to preserve both versions:
# 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.txtAfter resolving all conflicts, complete the operation:
For merge:
git commit -m "Resolve add/add conflict in file.txt"For rebase:
git rebase --continueIf you want to abort and start over:
# Abort merge
git merge --abort
# Abort rebase
git rebase --abortAdvanced 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.