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.
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.
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 --abort### 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.
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git