Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: patch cannot apply - missing header info

Tags:

git

patch

git-am

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?

like image 694
Jan Warchoł Avatar asked Aug 07 '26 02:08

Jan Warchoł


1 Answers

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.

like image 115
Jan Warchoł Avatar answered Aug 08 '26 20:08

Jan Warchoł



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!