Setup GPG for git on macOS

Install gnupg and pinentry-mac

brew install gnupg
brew install pinentry-mac

Generating a GPG key

Generating key

gpg --full-generate-key

Checking my key

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

Copying key

gpg --armor --export 3AA5C34371567BD2 | pbcopy

Setting key for git

git config --global user.signingkey 3AA5C34371567BD2

Full help

Setting to load key

nvim .gnupg/gpg-agent.conf

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

Backup and restore

gpg --export-secret-keys KEY_ID > my-private-key.asc
gpg --import my-private-key.asc

Possibly Related Posts