- Install gnupg
brew install gnupg
- Generate a new key
gpg --default-new-key-algo rsa4096 --gen-key
- Output key ID and remember it:
export KEY_ID="$(gpg --list-secret-keys --keyid-format LONG | head -3 | tail -1 | cut -c 15-30)"
- Export key
gpg --armor --export $KEY_ID
- Add it to GitHub https://github.com/settings/gpg/new
- Configure git
git config --global user.signingkey $KEY_ID
- Create a signed off commit
git commit -S -m "Initial commit"
I had some issues and this Stackoverflow answer helped me https://stackoverflow.com/a/47087248/14209416.
Here is useful link Renew expired GPG key (GitHub Gist).