Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge conflict error, when there was no change in mentioned file

Tags:

git

git-merge

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?

like image 823
klor Avatar asked May 15 '15 13:05

klor


People also ask

Why do I keep getting merge conflicts?

Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file. You must resolve all merge conflicts before you can merge a pull request on GitHub.


2 Answers

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

like image 58
klor Avatar answered Oct 23 '22 06:10

klor


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.

like image 43
Adarsh Avatar answered Oct 23 '22 04:10

Adarsh