How to sign git commits
2025-03-25
SSH Key Signing
- Create SSH key
ssh-keygen -t ed25519 -C "<comment>"
- Configure Git to use SSH for commit signing
git config --global gpg.format ssh
- Specify which public SSH key to use as the signing key and change the filename
git config --global user.signingkey ~/.ssh/examplekey.pub
- Auto sign commits:
git config --global commit.gpgsign true
GPG Key Signing
- Generate a new GPG key:
gpg --full-generate-key
- List your GPG keys:
gpg --list-secret-keys --keyid-format LONG
- Unset SSH signing:
git config --global --unset gpg.format
- Add the GPG key to Git:
git config --global user.signingkey <key-id>
- Auto sign commits:
git config --global commit.gpgsign true
More in-depth GPG Guide: Personal GPG Guide