From 4e7fc2e7d09a282ff9f2129f72d0aacd4b74926d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eahin=20Akkaya?= Date: Wed, 26 Jan 2022 16:55:20 +0300 Subject: [PATCH] TIL: Signing your commits with gpg key id --- git/signing-your-commits-with-gpg-key-id.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 git/signing-your-commits-with-gpg-key-id.md diff --git a/git/signing-your-commits-with-gpg-key-id.md b/git/signing-your-commits-with-gpg-key-id.md new file mode 100644 index 0000000..a0bfd68 --- /dev/null +++ b/git/signing-your-commits-with-gpg-key-id.md @@ -0,0 +1,20 @@ +If the name or email you are using for your gpg key does not match with the name or email used in git, you may get the following error while trying to sign your commit: +``` +error: gpg failed to sign the data +fatal: failed to write commit object +``` + +To fix this you need to get the your gpg key's id and configure git to use that instead. +``` +❯ gpg --list-keys --keyid-format short +/home/sahin/.gnupg/pubring.kbx +------------------------------ +pub rsa4096/CDA15ED2 2022-01-26 [SC] [expires: 2022-02-02] + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +uid [ultimate] Şahin Akkaya (Asocia) +sub XXXXXXX/XXXXXXXX 2022-01-26 [E] [expires: 2022-02-02] + +❯ git config --global user.signingKey CDA15ED2 +``` + +