11

After setting

$ gpg --list-keys
/home/pablo/.config/gnupg/pubring.gpg
-------------------------------------
pub   rsa4096/46F257F2 2014-09-16 [expires: 2015-09-16]
uid       [ultimate] Pablo Olmos de Aguilera Corradini (Personal) <mail@tld.com>

And putting the info on gitconfig:

[user]
    name = Pablo Olmos de Aguilera Corradini
    email = mail@tld.com
    signinkey = 46F257F2
[commit]
    gpgsign = true

I get:

gpg: skipped "Pablo Olmos de Aguilera Corradini <mail@tld.com>": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

As you can see the keys actually exists (they also appears when running gpg --list-secret-keys). If I remove everything from gitconfig, and try to do it only with -S, I get the same error, which makes me think that git is passing my user name and email to gpg, and the uid includes the "comment" (Personal), so it doesn't found any:

$ gpg --list-keys "Pablo Olmos de Aguilera Corradini <mail@tld.com>"
gpg: error reading key: No public key

I'm not sure if this is a bug from git, or it is the expected result and I'm missing something :).

PS.- My guess is that I could create another uid but without a comment, and it should work.

  • For signing only the secret key is needed. Therefore the output of `gpg --list-keys` is irrelevant. – michas Dec 14 '14 at 18:56
  • Are you using the same user for listing the keys and trying to sign with git? – Jens Erat Dec 14 '14 at 19:07
  • Does this answer your question? [git commit signing failed: secret key not available](https://stackoverflow.com/questions/36810467/git-commit-signing-failed-secret-key-not-available) – Michael Freidgeim Jun 15 '21 at 02:37

1 Answers1

11

There is a typo in your gitconfig. Should be signingkey, not signinkey

Martin
  • 911
  • 5
  • 7
  • 5
    That's one reason why you should use `git config` instead of manually editing entries in the `.gitconfig` file. – jub0bs Dec 14 '14 at 19:32
  • ARGH, that's stupid. I actually did use `git config`, but it seems I made that change by hand without noticing it :C. Marking your answer as accepted of course. – Pablo Olmos de Aguilera C. Dec 14 '14 at 20:36