Skip to content

Instantly share code, notes, and snippets.

@aint
Last active December 18, 2020 19:15
Show Gist options
  • Save aint/f56dd744cdd9817dd0a5bacd969ad8d7 to your computer and use it in GitHub Desktop.
Save aint/f56dd744cdd9817dd0a5bacd969ad8d7 to your computer and use it in GitHub Desktop.
How to enable macOS Keychain for gnuPG to automatically sign git commits

0) Import your privat key

$ gpg --import ~/.gnupg/gnupg-private-key.asc

1) Install the dependencies.

$ brew install gpg pinentry-mac

2) Configure git to automatically sign commits.

$ git config --global commit.gpgsign true

3) Add the following line to ~/.gnupg/gpg-agent.conf

pinentry-program /usr/local/bin/pinentry-mac

4) Add this line to ~/.gnupg/gpg.conf

no-tty

5) Finally you need to restart the gpg-agent

$ gpgconf --kill gpg-agent

Optional

6) List all GPG keys

$ gpg --list-keys

7) Select the one you added to github

$ git config --global user.signingkey [public key ID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment