没有完整的索引行,git无法应用二进制补丁***

Ros*_*one 54 git

当我尝试从文件中应用补丁时,我明白了

error: cannot apply binary patch to 'my/resource.png' without full index line
error: my/resource.png: patch does not apply

my/resource.png在提交中添加了补丁.如何启用全索引支持?

Ros*_*one 63

签出要从中创建补丁的分支.运行此命令:

git diff-index 79fd4d7 --binary > ~/Desktop/my-patch
Run Code Online (Sandbox Code Playgroud)

79fd4d7您想要区分的提交范围之前,提交的占位符在哪里.(例如,我想要一个包含前三个提交的补丁:

aaa02b0 third commit mine
aabbbcc second commit mine
bb82aed first commit mine
79fd4d7 old commit
Run Code Online (Sandbox Code Playgroud)

然后签出你的新分支并运行 git apply ~/Desktop/my-patch

  • 注意,重要的是`--binary`命令行选项,它由`diff`和`diff-index`支持. (25认同)
  • @kangear 刚刚解决了,添加`--reject`,所以`git apply --reject filename.diff` 将应用它可以应用的并拒绝其余的 (8认同)
  • 怎么忽略这个? (3认同)

tes*_*ing 7

如果您只删除了一些文件并收到相同的消息,我想以另一种方式发布。因为我无法再访问源代码(通过重置到另一个提交),所以我需要另一个解决方案(而不是创建新的补丁文件)。

因此我从补丁文件中删除了以下部分:

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
Run Code Online (Sandbox Code Playgroud)

之后我就可以成功应用我的补丁文件了!不知道他为什么要对已删除的文件进行二进制比较......