Skip to content

Instantly share code, notes, and snippets.

@tareqmamari
Last active July 30, 2020 23:53
Show Gist options
  • Save tareqmamari/4d0a075b5f1c7106f10466324402b19d to your computer and use it in GitHub Desktop.
Save tareqmamari/4d0a075b5f1c7106f10466324402b19d to your computer and use it in GitHub Desktop.
Setup git to sign commits and tags

Setup git to sign commits and tags

Prerequisite

brew install gnupg

Generate Key

gpg --gen-key

Configure Git to use the created Key

gpg --list-key
/Users/xyz/.gnupg/pubring.kbx
-------------------------------
pub   rsa2048 2020-05-28 [SC] [expires: 2022-05-28]
      XXXXXXXXXXXXXXXF44D6E037E8
uid           [ultimate] fname lname <[email protected]>
sub   rsa2048 2020-05-28 [E] [expires: 2022-05-28]

Copy the key id (XXXXXXXXXXXXXXXF44D6E037E8) to use it in the next step.

git config --global commit.gpgsign true
git config --local user.signingKey XXXXXXXXXXXXXXXF44D6E037E8

Troubleshooting

In case you experienced issues when sigining a commit/tag:

brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment