Git apply skips patches

☆樱花仙子☆ 提交于 2019-12-09 14:18:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!