Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 380
Anjo John Avatar asked Apr 22 '16 06:04

Anjo John


People also ask

How do I apply a binary patch in git?

In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.

How do git patch files work?

GIT patch or GIT diff is used to share the changes made by you to others without pushing it to main branch of the repository. This way other people can check your changes from the GIT patch file you made and suggest the necessary corrections.

Why is git apply skipping patch?

A patch is usually skipped when the changes it contains were already applied in the past. There are many possible reasons for this: a merge, a cherry-pick, changes operated manually or using another patch etc.

How does git treat binary files?

Git can usually detect binary files automatically. No, Git will attempt to store delta-based changesets if it's less expensive to (not always the case). Submodules are used if you want to reference other Git repositories within your project.


2 Answers

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.

like image 141
espinchi Avatar answered Sep 18 '22 14:09

espinchi


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.

like image 42
VonC Avatar answered Sep 17 '22 14:09

VonC