git apply对文件不做任何更改 [英] git apply is making no changes to files

查看:325
本文介绍了git apply对文件不做任何更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对我的仓库应用补丁并正在运行

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

git apply --directory=$PWD xxxxx.patch

出于我不愿讨论的原因,在这种情况下,我不能使用git am,而我需要使用目录标志.

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

git告诉我:

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

我已经读到,空格警告并不严重,也不应阻止git应用补丁.但是,无论出于何种原因,git都不会应用该修补程序.存储库中的当前文件均未更改.知道该怎么办吗?

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?

推荐答案

我注意到

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

读取提供的diff输出(即补丁")并将其应用于文件. 从存储库中的子目录运行时,将忽略目录外部的修补路径.使用--index选项...

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 ...

在这种情况下,git patch似乎正在确定文件在目录之外.如果从顶层运行,它应该停止确定(尽管$PWD本身也会改变;如果需要,任何--directory选项都将需要一个不同的参数).

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).

这篇关于git apply对文件不做任何更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆