'"No secret key" error when signing git commit on Windows

I'm getting this error when trying to sign a commit:

git commit -S -m "test"
gpg: skipped "EF617ACA9EC3XXXX": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

This is the output of gpg --list-secret-keys --keyid-format LONG

The key is present there

sec   rsa4096/EF617ACA9EC3XXXX 2020-05-17 [SC] [expires: 2022-05-17]
      AD68154000A712DCD161D826EF617ACA9EC3XXXX
uid                 [ultimate] name <[email protected]>

And this is git config with the same key

user.signingkey=EF617ACA9EC3XXXX
[email protected]

Any idea what's wrong?



Solution 1:[1]

git config --global gpg.program "c:/Program Files (x86)/GnuPG/bin/gpg.exe"

I installed with Kleopatra and generated my key within that. I was unable to create a commit until I ran the command above.

Solution 2:[2]

Was facing the same issue in windows 10 git bash. Doing this solved my problem. You could find this path by running where gpg

$ git config --global gpg.program "C:\Program Files\Git\usr\bin\gpg.exe"

Solution 3:[3]

In case anyone is a dufus like me I was getting this error because I had the gitkey wrong while directly editing the file via: git config --global -e or code ~/.gitconfig or whatever flavor of editor you enjoy.

  • singingkey ?? instead of
  • signingkey ????

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eric Milliot-Martinez
Solution 2 Naman Lakhwani
Solution 3 CTS_AE