I'm not sure when this error occurs, I haven't found any descriptions in google.
So my colleagues commited some new files and changed files on branch1. I then got these changes and merged them into my branch(branch2) but NOT using git merge but manually using beyond compare (I know it's a bad practice merging manually). However, after merging them manually and copy-pasting the new files in my branch as well, I commited the work in branch2. However, now, when they tried to get some changes from me using git merge origin/branch2 they receive a lot of git "add/add" conflicts on the new files they initially added.
Can anybody tell me why git sees these files as conflicts although they are the same? And how should these conflicts be handled?
You get CONFLICT (add/add): Merge conflict in ... conflicts because the files are in fact not the same. You can see the difference using the diff
command, for example:
git diff branch1 branch2 -- path/to/file
where branch1
and branch2
are the names of the branches you want to compare.
Or, an easier way to see the difference, right after the failed git merge
when you are in the conflicted state, you can simply run git diff
without parameters, it will reveal the conflicted regions.
To resolve such conflict, you have to decide which branch has the right content. You can do that by checking out the file from the appropriate branch, for example:
git checkout name_of_branch path/to/file
Sometimes the right content is a mix of the two files. In that case you have to resolve manually, possibly by studying the differences using the git diff
command, as in the examples above.
The long-term solution is to avoid making conflicting changes to the same paths in different branches, which is typically a task sharing / communication issue between collaborators.
I had a git (Add/Add) conflict. The information from Janos provided the insight needed for a solution. The files "appeared" identical, but my conflicting folder of files were added with a permission of 664 on one branch, and a permission of 755 on another branch. Using git status revealed the difference between the files.
Steps taken to resolve the conflict:
git merge --abort
rm -rfv myconflictedfolder
git commit -m'Resolve git Add/Add branch merge conflict by deleting conflicted folder and files in myconflictedfolder'
git merge mybranch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With