git

git commit signing failed: secret key not available


I am getting this error when trying to commit using Git.

gpg: skipped "name <name@mail.com>": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign the data
fatal: failed to write commit object

I have generated a new key as below but it still gives the same error

gpg --list-keys
~/.gnupg/pubring.gpg
--------------------------------
pub   2048R/35F5FFB2 2016-04-23
uid                  name (New key) <name@mail.com>
sub   2048R/112A8C2D 2016-04-23

The secret key is the same as above

I have found this Generating a GPG key for git tagging and followed the steps but it still doesn't work, any idea?


Solution

  • You need to configure the secret key before using it.

    git config user.signingkey 35F5FFB2
    

    Or declare it globally if you want to use the same key for every repository.

    git config --global user.signingkey 35F5FFB2
    

    Source: Git Tools - Signing Your Work