Skip to content

Instantly share code, notes, and snippets.

@ruimaranhao
Last active January 17, 2019 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruimaranhao/078d1328e95f4571e0a489af77d13f7e to your computer and use it in GitHub Desktop.
Save ruimaranhao/078d1328e95f4571e0a489af77d13f7e to your computer and use it in GitHub Desktop.
Using gpg to sign git commits (MacOS)

Run the following to install the gpg agent:

brew upgrade gnupg  # This has a make step which takes a while
brew link --overwrite gnupg
brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent

echo "test" | gpg --clearsign

Configure git to sign the messages:

git config --global gpg.program gpg  # perhaps you had this already? On linux maybe gpg2
git config --global commit.gpgsign true  # if you want to sign every commit

gpg --list-secret-keys --keyid-format LONG

git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)

Use the following command to show signed commits in git log

git log --show-signature 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment