Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to resolve Git conflict with binary files

📅 2016-Apr-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ conflict, git, merge ⬩ 📚 Archive

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


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧