I created a diff file by a command:
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
During the execution I encountered an error:
error: git diff header lacks filename information when removing 1 leading pathname component (line 2138)
Line 2138 leads to:
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 ......
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.
Most probably because you have this setting in the git config
(~/.gitconfg):
[diff]
noprefix = true
So, you can remove it or change to false:
git config --global diff.noprefix false
you can try this.
patch -p0 < filename
This patch command reads a source file's instructions on how to change a file, then applies the changes. The source file contains difference listings (or diff listings) and one or more sets of diff command output, like called hunks.
The patch command skips any leading text in a patch file, applies the actual diff listing, and skips any trailing text. Thus, you could use as a patch file or message that includes a diff listing, and the patch command would still work. In such a case, if the entire diff listing is indented by a consistent amount, the patch command will also adjust for that spacing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With