Git Signing
Git Signing: Proving Commit Authorship Cryptographically
By default, anyone can set git config user.name and user.email to impersonate another developer's commits. Cryptographic commit signing attaches a digital signature generated by your private key so GitHub, GitLab, and teammates can verify that a commit genuinely came from you and was not tampered with.
Easy Commit Signing with Your Existing SSH Key
Modern Git (2.34+) lets you sign commits directly with the same Ed25519 SSH key you already use for authentication—no complex GPG setup required:
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true
git config --global tag.gpgsign true
On GitHub, go to Settings > SSH and GPG keys > New SSH key, set Key type to Signing Key, and paste the contents of ~/.ssh/id_ed25519.pub. Every commit and annotated tag you push now displays a green Verified badge.
Signing with GPG (Traditional Method)
Teams using GPG hardware tokens or existing PGP workflows configure their GPG key ID instead:
gpg --list-secret-keys --keyid-format=long
git config --global user.signingkey YOUR_KEY_ID
git config --global commit.gpgsign true
Verifying Signatures Locally
Inspect cryptographic signatures directly from your terminal using --show-signature or -S when creating an ad-hoc signed commit:
git commit -S -m "Sign release configuration update"
git log --show-signature -n 3
For local SSH verification, point gpg.ssh.allowedSignersFile to a file mapping teammate emails to their public SSH keys.
Common Signing Mistakes
Uploading your SSH key to GitHub only as an Authentication Key without adding it a second time as a Signing Key leaves pushed commits marked Unverified. Add the .pub key under both key types on GitHub.
Frequently Asked Questions
Does commit signing encrypt my source code?
No. Signing adds a cryptographic signature proving authorship and integrity, while the commit diff and message remain readable to anyone with repository access.
Can I sign commits with a hardware security key like a YubiKey?
Yes. Both GPG keys stored on smartcards and FIDO2 ed25519-sk SSH keys work smoothly with Git commit signing.
What happens if someone alters a single character of a signed commit?
The commit's SHA hash and cryptographic signature break immediately, flagging the commit as invalid or unverified.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With