How to sign git commits

2026-10-19

  1. Generate SSH Key (though existing one can be used also)
ssh-keygen -t ed25519 -C "1190812+alexgalkin@users.noreply.github.com" -f ~/.ssh/github_signing_key
  1. View and copy the full public key and add it to your GitHub profile as a Signing key
cat ~/.ssh/github_signing_key.pub
  1. Configure your new key for signing using git
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/github_signing_key.pub
  1. And when you do commits use -S parameter
git commit -S -m "fix: resolved the issue with keys signing"
  1. Let Git verify those signatures locally by listing your email and public key as an allowed signer
mkdir -p ~/.config/git
echo "$(git config user.email) $(cat ~/.ssh/github_signing_key.pub)" > ~/.config/git/allowed_signers
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signers
  1. Sign every commit by default, and show the signature status in git log
git config --global commit.gpgsign true
git config --global log.showSignature true

Useful references: