I'm getting this error when trying to apply a patch using git am:
error: git diff header lacks filename information
when removing 1 leading pathname component (line 9)
The patch was created using git's own format-patch command and not edited in any way, what's wrong?
Turned out it was because I had disabled filename prefixes in git diff output (noprefix = true in your .gitconfig). They are not useful when reading git diff output, but apparently git patches rely on them.
You can check what's your setting with
git config --get diff.noprefix
If it returns true, try disabling the setting with
git config --global diff.noprefix false
(you can omit --global flag if you want to make a change only for current repo).
Patches generated afterwards worked fine for me.
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