2023-11-14
I spent much time trying to figure out the following error when trying to sign a commit:
gpg: skipped "Foo Bar <FooBar@baz>": No secret key[GNUPG:] INV_SGNR 9 FooBar <FooBar@baz>[GNUPG:] FAILURE sign 17
gpg: signing failed: No secret key
After searching and coming up empty handed, one thing stood out. The name
and email in ~/.gitconfig must match exactly to the name and
email associated with the GPG key:
$ gpg --list-secret-keys --keyid-format=long
/home/foo/.gnupg/pubring.kbx
-----------------------------
sec rsa4096/FC53C827D09C7050 2019-03-24 [SC]
ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
uid [ultimate] Foo Bar <Foo_Bar@baz>
ssb rsa4096/2EE67124D597BB00 2019-03-24 [E]
$ head -n 4 .gitconfig
[user]
name = Foo Bar
email = Foo_Bar@baz
signingkey = FC53C827D09C7050