Why is git apply of a patch with binary files not creating the binary files?

16,844

Solution 1

The --binary option is used when you create the patch file, not when you apply it.

That means, instead of your current git diff branch1 branch2 > patch-file, you have to do this instead: git diff branch1 branch2 --binary > patch-file. And, then, apply the patch with git apply patch-file in the same way as you're doing.

Solution 2

I tried the git apply with --binary option.

That wouldn't affect anything: the git apply man page mentions:

Historically we did not allow binary patch applied without an explicit permission from the user, and this flag was the way to do so. Currently we always allow binary patch application, so this is a no-op.

So check your git status and permissions on your repo, as well as your git version.
As a test, try apply that patch on a new repo.

Share:
16,844
Anjo John
Author by

Anjo John

Updated on July 12, 2022

Comments

  • Anjo John
    Anjo John almost 2 years

    I have a git patch with two binary files (it's libraries, newly added). I tried to apply the patches but the binary files are not created. I tried git apply with the --binary option. Is there any other option to add the binary files from git patch? I only need the binary files.