How to setup a GPG key in Git

This page is going to assume that a key has already been created on the system and added to GitHub through the web interface.

To set the list of keys on the system

gpg --list-secret-keys --keyid-format=long

To configure git to use the key

git config --global user.signingkey <keyid-from-step-above>

To set git to sign commits by default

git config --global commit.gpgsign true

To add the key to the .zshrc (or .bashrc)

#In ~/.zshrc
export GPG_TTY=$(tty)

If "keep my email private" has been enabled in GitHub, then the email associated with the key must match the no-reply email provided by GitHub.