如果没有完整的索引行,git 无法应用二进制补丁 ***
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17152171/
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
git cannot apply binary patch *** without full index line
提问by Rose Perrone
When I try to apply a patch from a file, I see
当我尝试从文件应用补丁时,我看到
error: cannot apply binary patch to 'my/resource.png' without full index line error: my/resource.png: patch does not apply
I added my/resource.png
in the commit from which I made the patch. How can I enabled full-index support?
我添加my/resource.png
了我制作补丁的提交。如何启用全索引支持?
回答by Rose Perrone
Checkout the branch from which you want to create the patch. Run this command:
签出要从中创建补丁的分支。运行此命令:
git diff-index 79fd4d7 --binary > ~/Desktop/my-patch
Where 79fd4d7
is a placeholder for the commit that came right before the range of commits you want to diff. (e.g. I want a patch that contains the first three commits below:
在79fd4d7
您要区分的提交范围之前的提交的占位符在哪里。(例如,我想要一个包含以下前三个提交的补丁:
aaa02b0 third commit mine
aabbbcc second commit mine
bb82aed first commit mine
79fd4d7 old commit
Then checkout your new branch and run git apply ~/Desktop/my-patch
然后检出你的新分支并运行 git apply ~/Desktop/my-patch
回答by testing
I want to post another way if you have only deleted some filesand get the same message. Because I didn't had access to the source code anymore (through reset to another commit), I needed another solution (instead of creating a new patch file).
如果您只删除了一些文件并收到相同的消息,我想以另一种方式发布。因为我无法再访问源代码(通过重置为另一个提交),所以我需要另一个解决方案(而不是创建新的补丁文件)。
Therefore I deleted the following parts from my patch file:
因此,我从补丁文件中删除了以下部分:
diff --git a/MyProject/Libraries/some.dll b/MyProject/Libraries/some.dll
deleted file mode 100644
index a0908d7..0000000
Binary files a/MyProject/Libraries/some.dll and /dev/null differ
diff --git a/MyProject/Libraries/some.dll.mdb b/MyProject/Libraries/some.dll.mdb
deleted file mode 100644
index d3c3912..0000000
Binary files a/MyProject/Libraries/some.dll.mdb and /dev/null differ
Afterwards I could apply my patch file with success! Don't know why he wants to make a binary compare on a deleted file ...
之后我可以成功应用我的补丁文件!不知道他为什么要对删除的文件进行二进制比较......