How to resolve Git conflict with binary files

If a binary file in a Git repository has changed between your branch and the branch you try to merge, you will get a merge conflict. Since it is a binary file, you typically cannot use a 3-way merge tool to fix this. In most cases, you know that either you want to keep your version of the file or the one you are merging from.

To commit your file:

$ git checkout --ours -- somepath/foobar.bin
$ git add somepath/foobar.bin
$ git commit

To commit the file from the other branch:

$ git checkout --theirs -- somepath/foobar.bin
$ git add somepath/foobar.bin
$ git commit

Tried with: Git 2.4.1 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s