How to handle/fix git add/add conflicts?
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?
2 Solutions collect form web for “How to handle/fix git add/add conflicts?”
You get CONFLICT (add/add): Merge conflict in … conflicts because the files are in fact NOT exactly the same. They may look pretty much the same from a distance, but they are definitely different.
If there is even one bit of difference, Git cannot know which file is the right one. One branch says “add this file”, another branch says “add this file”, with same name but different content, only you can tell which one is the right one.
You can confirm the difference with:
git diff other_branch path/to/file
Or after the merge, in the conflicted state, you can see the problem with simply
To resolve such conflict, you have to decide which branch has the right content, and checkout the file from that branch. To choose the version in the current branch:
git checkout path/to/file
To choose the version in the other branch:
git checkout other_branch path/to/file
The long-term solution is to avoid practices that you already know yourself to be bad.
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