How to set up git commit signing:
Make sure you have gpg
installed, and user.email
configured for git.
Enable GPG Agent:
add use-agent
line to ~/.gnupg/gpg.conf
(create file if not exists).
Start GPG agent on a shell launch, add to your .zshrc
:
export GPG_TTY=$(tty)
gpgconf --launch gpg-agent
Generate new key gpg --full-gen-key
or import the existing one.
You can verify you have a private key with gpg --list-secret-keys --keyid-format SHORT
.
Configure Git to sign your commits with GPG key:
# Replace 674CB45A with your key ID from a command above
git config --global user.signingkey 674CB45A
git config --global commit.gpgSign true
git config --global tag.gpgSign true
Add public key to GitHub profile:
# Replace 674CB45A with your key ID
gpg --armor --export 674CB45A
Commit or --amend something, check that it works with git log --show-signature -1
.
Source https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html.