我通过命令创建了一个差异文件:
git --no-pager diff --no-index --stat pathA pathB >\diff.log
接下来,我执行了一个命令:
git apply --index --ignore-space-change --ignore-whitespace \diff.log
在执行过程中,我遇到了一个错误:
error: git diff header lacks filename information when removing 1 leading pathname component (line 2138)
第 2138 行导致:
2136 diff --git a/C:\Temp\right_tmp5D66/file.cpp b/file.cpp
2137 new file mode 100644
2138 index 0000000000000000000000000000000000000000..e69de...
2139 diff --git ......
我试过一个命令“git apply --reject ...”但它也没有用。我还添加了忽略 chmod 更改的配置(git config core.fileMode false)并且没有任何更改。
最佳答案
很可能是因为您在 git config
中有此设置(~/.gitconfg):
[diff]
noprefix = true
因此,您可以将其删除或更改为 false:
git config --global diff.noprefix false
关于git - 执行 git apply 时出现错误 "git diff header lacks filename information when removing 1 leading pathname component ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54011629/