0

I am working on Git.I was merging one binary file it gave me conflicts.

Can someone please tell me why binary files conflicts. What are the causes.Is it because of the uncommitted changes on current branch or its just because of the different versions of the binary files?

AB Bolim
  • 1,997
  • 2
  • 23
  • 47
mrutyunjay
  • 6,850
  • 7
  • 25
  • 35

1 Answers1

0

If the binary file was changed in more than one branch that is part of the merge, Git will always create a conflict since it cannot apply its merge strategies that are designed for text files. This is because usually you can't just move binary chunks around without completely corrupting the file. Also, what would the semantics be of e.g. merging an image file?

It's up to you to decide what you want to do. You might want to keep one of the versions, or perhaps, if it's image files, you want to "manually merge" them using a graphics manipulation program. Git really can't help you here.

Michael Wild
  • 24,977
  • 3
  • 43
  • 43
  • this is partly true, but it is incorrect to say that git cannot help. Git is especially good in helping among version control systems, as it provides a way to act reasonably even on binary conflicts, using external merge software. See an [example](http://www.superjer.com/forum/let_git_help_you_merge_images.php) for images. – eis Apr 09 '13 at 06:28
  • 1
    That's true, you can tell git that there's a merge program for a given file type. In that sense it **is** helpful. But it can't perform the merge-resolution for you. – Michael Wild Apr 09 '13 at 06:30
  • How can you tell Git which version you want to keep? – ryansin Dec 20 '16 at 11:13
  • Just move the version you want in place and use `git add` on it to add it to the index. – Michael Wild Dec 20 '16 at 17:04