为什么带有二进制文件的补丁的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:57:38  来源:igfitidea点击:

Why is git apply of a patch with binary files not creating the binary files?

gitbinarydiffpatch

提问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 applywith the --binaryoption. 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 --binaryoption 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-filein 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 applyman pagementions:

那不会做任何事情:git apply手册页提到:

Currently we always allow binary patch application, so this is a no-op.

目前我们总是允许二进制补丁应用程序,所以这是一个空操作。

So check your git statusand 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 版本。
作为测试,尝试将该补丁应用于新的存储库。