How to sign git commits

2025-03-25

SSH Key Signing

  1. Create SSH key ssh-keygen -t ed25519 -C "<comment>"
  2. Configure Git to use SSH for commit signing git config --global gpg.format ssh
  3. Specify which public SSH key to use as the signing key and change the filename git config --global user.signingkey ~/.ssh/examplekey.pub
  4. Auto sign commits: git config --global commit.gpgsign true

GPG Key Signing

  1. Generate a new GPG key: gpg --full-generate-key
  2. List your GPG keys: gpg --list-secret-keys --keyid-format LONG
  3. Unset SSH signing: git config --global --unset gpg.format
  4. Add the GPG key to Git: git config --global user.signingkey <key-id>
  5. Auto sign commits: git config --global commit.gpgsign true

More in-depth GPG Guide: Personal GPG Guide