How to resolve binary file conflicts in Git

Binary file conflicts in Git are particularly challenging because you cannot manually merge them like text files—you must choose one complete version over another. With over 25 years of software development experience and as the creator of CoreUI, I’ve managed binary assets like images, fonts, and compiled files in numerous projects. When Git encounters conflicts in binary files during merges or rebases, it cannot perform automatic merging and requires you to explicitly choose either the current branch version or the incoming branch version. The solution involves using git checkout with --ours or --theirs flags to select the desired version.

Use git checkout --ours or git checkout --theirs to resolve binary file conflicts by choosing one version.

# After merge conflict occurs with binary file (e.g., logo.png)
git status

# Keep your current branch version
git checkout --ours path/to/logo.png

# Or keep the incoming branch version
git checkout --theirs path/to/logo.png

# Stage the resolved file
git add path/to/logo.png

# Continue with merge or rebase
git commit

Best Practice Note

The --ours flag keeps the version from your current branch (HEAD), while --theirs keeps the version from the branch being merged in. For binary files, you cannot combine changes like you can with text files—you must choose one complete file. If you need both versions, rename one file before committing. Consider using Git LFS (Large File Storage) for binary assets to reduce repository size and improve conflict handling. This is how we manage design assets in CoreUI repositories—using descriptive filenames and clear versioning to minimize binary conflicts during collaborative development.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author