为什么带有二进制文件的补丁的 git apply 不创建二进制文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36786345/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is git apply of a patch with binary files not creating the binary files?
提问by Anjo John
I have a git patch with two binary files (it's libraries, newly added). I tried to apply the patches but the binary files are not created. I tried git apply
with the --binary
option. Is there any other option to add the binary files from git patch? I only need the binary files.
我有一个带有两个二进制文件的 git 补丁(它是新添加的库)。我尝试应用补丁,但未创建二进制文件。我试过git apply
这个--binary
选项。还有其他选项可以从 git patch 添加二进制文件吗?我只需要二进制文件。
回答by espinchi
The --binary
option is used when you create the patch file, not when you apply it.
该--binary
选项在您创建补丁文件时使用,而不是在您应用它时使用。
That means, instead of your current git diff branch1 branch2 > patch-file
, you have to do this instead: git diff branch1 branch2 --binary > patch-file
. And, then, apply the patch with git apply patch-file
in the same way as you're doing.
这意味着,而非目前git diff branch1 branch2 > patch-file
,你必须这样做,而不是:git diff branch1 branch2 --binary > patch-file
。然后,以与git apply patch-file
您相同的方式应用补丁。
回答by VonC
I tried the git apply with --binary option.
我尝试了 git apply 与 --binary 选项。
That wouldn't do anything: the git apply
man pagementions:
那不会做任何事情:git apply
手册页提到:
Currently we always allow binary patch application, so this is a no-op.
目前我们总是允许二进制补丁应用程序,所以这是一个空操作。
So check your git status
and permissions on your repo, as well as your git version.
As a test, try apply that patch on a new repo.
因此,请检查您git status
对 repo 的 和 权限,以及您的 git 版本。
作为测试,尝试将该补丁应用于新的存储库。