Git commit error: cannot spawn gpg.exe: No such file or directory

6.8k Views Asked by At

This is what I am getting as output when I am trying to commit any file. I tried installing git again and watched some tutorials on youtube to get it started again but it didn't work. Still getting the same error:

error: cannot spawn C:\Program Files (x86)\GnuPG\bin\gpg.exe: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
3

There are 3 best solutions below

1
On

If you are using Git bash in Windows to generate the key instead of GnuPG Win, then you need to update the git config to point to the right location of gnupg. Run the following command in git bash with the correct location.

git config --global gpg.program /usr/bin/gpg

If you don't know the location run which gpg in git bash to obtain the location.

0
On

I also faced this issue and was able to fix it by removing quotes for the gpg.exe program line in .gitconfig file.

.gitconfig file before update =>

[gpg] program = 'C:\Users\TEST\AppData\Local\GnuPG\bin\gpg.exe'

.gitconfig file after update =>

[gpg] program = C:\Users\TEST\AppData\Local\GnuPG\bin\gpg.exe

0
On

Judging from the error message:

error: cannot spawn C:\Program Files (x86)\GnuPG\bin\gpg.exe: No such file or directory
error: gpg failed to sign the data fatal: failed to write commit object

you have git gpg signing turned on but no GnuPG installed. Either install it or turn off commit gpg signing. You can disable commit signing using --no-gpg-sign flag on a particular commit command:

git commit --no-gpg-sign

or disable it permanently by modyfing your global .gitconfig:

git config --global commit.gpgsign false