I'm trying to apply a patch that includes binary files with git apply
but only the files are added. I tried running git apply failing.patch -v
and it prints something like:
Skipped patch 'file.txt'.
Checking patch file.bin...
Applied patch file.bin cleanly.
How can I find out what's the reason of the skip? As the current message is not very enlightening.
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.
git apply takes a patch (e.g. the output of git diff ) and applies it to the working directory (or index, if --index or --cached is used). git am takes a mailbox of commits formatted as an email messages (e.g. the output of git format-patch ) and applies them to the current branch.
I found out the problem by running patch -p1 < failing.patch
which printed:
can't find file to patch at input line 5
and reminded me that I was not in the root directory.
I can't understand why no one had asked this before and why is the verbose message not verbose.
Also, not even the official documentation mentions skipping and possible causes.
If you use the --directory option to "git apply":
--directory=<root>
that path is RELATIVE TO THE BASE DIRECTORY (the one containing ".git"), not relative to the current working directory. You cannot use an absolute path either.
This is completely undocumented and took me hours to discover.
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