13

I have a site local repo and a remote repo. Local repo contains the 1-2 month old content of remote repo.

I try to pull the whole content into local repo.

git pull origin master
From ssh://.../site.git
 * branch            master     -> FETCH_HEAD
...
CONFLICT (add/add): Merge conflict in admin/process_email.php
Automatic merge failed; fix conflicts and then commit the result.

I checked process_email.php using P4Merge, but shows no conflict, furthermore there were no changes at all, no difference.

UPDATE:

I get

$ git status
On branch master
nothing to commit, working directory clean on both repos. 

Also I tried

$ git pull -X theirs origin/master master

But still get the same error.

I want to merge the remote origin repo with my local repo. I want to overwite local repo with remote origin repo content as the remote repo is newer, contains the latest code.

More than 2000 files are conflicting, while I checked the conflict and they have the same content. I would not want to do manual conflict handling.

I have autocrlf = False in the .gitconfig.

Why do I get conflict error for files, which have exactly the same content?

klor
  • 1,237
  • 4
  • 12
  • 37
  • Try open file in notepad or notepad++ and look to any tag that indicates merge failing, there's someone? – Ricardo Silva May 15 '15 at 13:43
  • There are no any tags, yet. – klor May 15 '15 at 14:39
  • That's extremely weird. If you get the error "CONFLICT (add/add): Merge conflict in xxx", then there should be conflict markers in the file, and `git status` should report the file as a conflict (text: "both added"). – sleske May 15 '15 at 14:59
  • I'm 99.9% sure you didn't run `git status` in the same repo and right after you got a conflict. But if you want to discard all your local changes, why are you running `git pull` which is meant to *merge* your changes with the remote? – Matthieu Moy May 15 '15 at 15:06
  • I also have Git Extensions open, so I immediately see if there are changes which are not committed, yet. This is why I wrote, that more than 2000 files are conflicting. I use git pull, and I wrote after UPDATE: git pull -X theirs origin/master master – klor May 15 '15 at 17:39
  • Yes git status shows files as a conflict (text: "both added"). BTW: Both repo has just one commit, the initial commit. This is the problem? – klor May 15 '15 at 17:42

3 Answers3

5

Finally solved the problem, based on solution used in following thread:

How to handle/fix git add/add conflicts?

# moved all files from the local workdir to another directory.
mv /workdir/* /old_content

# commit this change
git commit -m 'Resolve git Add/Add branch merge conflict by deleting conflicted folder and files in myconflictedfolder'

# do merge from remote
git pull origin master

Pull was executed successfully, no conflicts anymore.

I could now overwrite the old_content directory, if I want, then commit.

Best regards, Konrad

Community
  • 1
  • 1
klor
  • 1,237
  • 4
  • 12
  • 37
  • I've also had success moving the few necessary files to a new directory. Deleting the local brach, and recreating the branch. – Paul Bendevis May 11 '18 at 19:42
2

This can also occur if someone has forced push on the remote. Quick fix is to reset hard on your local and then take pull

  • git reset --hard origin/master
  • git pull

Also one should avoid git force push.

Adarsh
  • 79
  • 1
  • 2
  • An `add/add` conflict is not the results of a forced push, it is the result of adding the same file(s) in both branches. This solution will work anyway, though, when one is willing to discard the local branch. – joanis May 26 '21 at 12:42
0

The messages says you have a add/add conflict, meaning that the file was added both in your branch and in the one you're merging. This limits Git's ability to merge because there's no common ancestor (i.e. you'll get conflicts for every part of the file different on both sides). Open the file in your text editor and see if you have conflict markers and resolve them.

Running git status will give you more information about what's goin on.

Once you're satisfied with the content of the file, run git add on it and git commit.

Matthieu Moy
  • 15,151
  • 5
  • 38
  • 65