git apply is making no changes to files

南楼画角 提交于 2019-12-05 03:10:16

问题


I have to apply a patch to my repo and am running

git apply --directory=$PWD xxxxx.patch

For reasons I won't go into, I cannot use git am in this instance, and I need to use the directory flag.

git tells me:

$> git apply --directory=$PWD xxxxx.patch
code1/xxxxx.patch:337: trailing whitespace.
         < one partial line of code >
warning: 1 line adds whitespace errors.

I have read that the whitespace warning is nothing serious and should not stop git from applying the patch. However, whatever the reason, git is not applying the patch. None of the current files in the repo are changing. Any idea what to do about this?


回答1:


I note the following boldfaced (my boldface) sentence in the git apply documentation:

Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the --index option ...

It seems in this case that git patch is deciding that the files are outside the directory. If run from the top level, it should stop deciding that (though of course $PWD itself will change too; any --directory option, if one is required, would need a different argument).



来源:https://stackoverflow.com/questions/45490424/git-apply-is-making-no-changes-to-files

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