当删除1个前导路径名组件时,错误"git diff头缺少文件名信息".当执行git apply时 [英] Error "git diff header lacks filename information when removing 1 leading pathname component " when executing git apply
问题描述
我通过命令创建了一个差异文件:
I created a diff file by a command:
git --no-pager diff --no-index --stat pathA pathB> \ diff.log
git --no-pager diff --no-index --stat pathA pathB >\diff.log
接下来,我执行了一条命令:
Nextly, I executed a command:
git apply --index --ignore-space-change --ignore-whitespace \ diff.log
git apply --index --ignore-space-change --ignore-whitespace \diff.log
在执行过程中,我遇到了一个错误:
During the execution I encountered an error:
错误:删除1个领先的路径名组件时,git diff标头缺少文件名信息(第2138行)
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
2136 diff --git a/C:\Temp\right_tmp5D66/file.cpp b/file.cpp
2137新文件模式100644
2137 new file mode 100644
2138索引0000000000000000000000000000000000000000..e69de ...
2138 index 0000000000000000000000000000000000000000..e69de...
2139 diff --git ......
2139 diff --git ......
我尝试了一个命令"git apply --reject ...";但它也不起作用.我还添加了忽略chmod更改的配置(git config core.fileMode为false),并且没有任何更改.
I have tried a command "git apply --reject ..." but it also didn't work. I also added config which ignores chmod changes (git config core.fileMode false) and nothing was changed.
推荐答案
最可能是因为您在git config
(〜/.gitconfg)中具有此设置:
Most probably because you have this setting in the git config
(~/.gitconfg):
[diff]
noprefix = true
因此,您可以将其删除或更改为false:
So, you can remove it or change to false:
git config --global diff.noprefix false
这篇关于当删除1个前导路径名组件时,错误"git diff头缺少文件名信息".当执行git apply时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!