5

How do I resolve a binary file conflict resolution during a merge operation in git? Here's what I've done so far:

git checkout master
git fetch origin
git merge working_branch

... [Conflicts] ...

git status
...
Unmerged paths:
        both modified:   Path/file.dll
        ...

I want to keep the version in the working_branch and discard the version in the master. How do I do this?

Jim Fell
  • 13,750
  • 36
  • 127
  • 202
  • Generally you would select one version or the other, unless there is a feasible way outside of `git` to actually create some sort of merged version (which is unlikely with DLLs, but completely possible with e.g. JAR or ZIP files...). You can select one or the other with e.g. `git checkout -- :2:Path/file.dll` or `git checkout -- :3:Path/file.dll` for the HEAD and MERGE_BRANCH versions, respectively. See `git help merge` for more details... – twalberg Apr 01 '15 at 18:04
  • Oops... wrong syntax - should be `git show :2:Path/file.dll > Path/file.dll`, and similar for the slot 3 entry... Doesn't work with `git checkout`; although there is alternative syntax - `git checkout --ours -- Path/file.dll` or `git checkout --theirs -- Path/file.dll`... – twalberg Apr 01 '15 at 18:11
  • Does this answer your question? [Resolving a Git conflict with binary files](https://stackoverflow.com/questions/278081/resolving-a-git-conflict-with-binary-files) – starball Mar 22 '21 at 19:18

1 Answers1

10

Figured it out earlier today:

git checkout --theirs Path/file.dll
git add Path/file.dll
git commit -m "Resolved merge conflict by checking out file from working_branch and adding it to the master"
Jim Fell
  • 13,750
  • 36
  • 127
  • 202