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.
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With