Resolving Merge Conflicts in Binary Files1 min read

Merge graphic by Bluetip Design.

I had this come up today and thought it might be useful for someone else.

Have you gone to run git pull --rebase only to find you have a merge conflict? That’s common enough, and resolving those conflicts is reasonably strait-forward thanks to git’s helpful in-file indicators. But how do you resolve a conflict that’s in a binary file, like an image?

I ran into that today with a bunch of image files. It turns out the solution is pretty quick.

If you want to take your changes over the ones you’re merging in, simply run:

git checkout --ours -- path/to/file.jpg

Inversely, if you want to take the merging changes over your own you can run:

git checkout --theirs -- path/to/file.jpg

This works on non-binary files, too, but keep in mind it’s all-or-nothing. Either use all your changes to a file, or all theirs.

I’m a full-stack web developer from Seattle. I love building software with an eye for quality and writing about the process.

Leave a Reply

Your email address will not be published. Required fields are marked *