I finished a git push to a Bitbucket repository and in the Bitbucket account I found these update were done. But when I do a git pull in a production CentOS server, I got error below. Does anyone know the reason and how to fix it?

xxxx@VM02 sha-ferrero-kinder_201661]$ sudo git pull
[sudo] password for XXXX:

**warning: Cannot merge binary files: images/Win/WinDisney.png (HEAD vs. 80e984389135a54b8062497fb5c202efcc89fc57)
Auto-merging images/Win/WinDisney.png
CONFLICT (add/add): Merge conflict in images/Win/WinDisney.png
Automatic merge failed; fix conflicts and then commit the result.**

Detail shown in attachment:

enter image description here

  • 1
    try git mergetool, which might fix your problem – Rahul Jul 29 '16 at 11:39
  • 4
    why do you push with sudo? – schaiba Jul 29 '16 at 11:39
  • 1
    What is the version of WinDisney you consider right, the one from the remote or the local version? – Luciano Andress Martini Jul 29 '16 at 11:40
  • 2
    This is a free advice service. We have whatsoever no concept of urgency. – Rui F Ribeiro Jul 29 '16 at 11:43
  • 2
    Also, please don't post images of text – ilkkachu Jul 29 '16 at 12:21

The file in your working copy is still the copy from your current branch – in other words, it was not modified by the merge attempt. To resolve the conflict and keep this file:

$ git add WinDisney.png 
$ git commit –m “My commit message for the merge”

If you prefer to resolve the conflict using their copy, you need to get the version of the file from the branch you were trying to merge in:

$ git checkout --theirs -- WinDisney.png

Alternatively you can try:

git mergetool

It opens a GUI that steps you through each conflict, and you get to choose how to merge. Sometimes it requires a bit of hand editing afterwards, but usually it's enough by itself. It is much better than doing the whole thing by hand certainly.

(Note : git mergetool doesn't necessarily open a GUI unless you install one.

  • @Franklin_hong did that helped you ? If yes, then you can consider accepting answer by clicking on right mark below up/down arrow – Rahul Aug 1 '16 at 6:40
  • Dear Rahul, Thank you for your advice. I prefer to use git checkout to fix the issue. And the file in remote is the newest one for the git pull. So how to know the version for the file? If I need to git pull it from remote origin do I need to use "git checkout --theirs --WinDisney.png" directly? – Franklin_hong Aug 1 '16 at 6:45
  • @Franklin_hong yes, if that doesn't help you, you would have to use git checkout WinDisney.png file/to/restore – Rahul Aug 1 '16 at 7:03
  • OK, I can't do the fix due to I need to get approval from my IT boss then I can do your method. But I will do it in near future. And I think your answer can work for the fix. Thank you and have a nice day! – Franklin_hong Aug 1 '16 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.