1

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?

Jan Warchoł
  • 933
  • 6
  • 21

1 Answers1

4

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.

Jan Warchoł
  • 933
  • 6
  • 21