问题
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.
回答1:
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.
回答2:
Suffering this issue whilst attempting to port changes across projects. git apply
seems to ignore any directory names on the patch file paths, also it refuses to apply if the Index line does not match a file hash in the target repository. I had better success using these options (of which --no-index
seems to be undocumented):
git apply --verbose --no-index --directory {subdir} {patch-file}
回答3:
Got the same issue. In my case the source of error was .git
folder in some of parent directories of the patch target. The solution was to move patch target outside that parent directory.
来源:https://stackoverflow.com/questions/42386491/git-apply-skips-patches