Git allows you to sign commits and tags using cryptographic keys (GPG or SSH) to verify authorship and integrity. Signed commits help ensure that changes come from trusted sources and have not been tampered with.
When a commit or tag is signed, Git embeds a cryptographic signature generated using your private key. Others can verify this signature using your public key to confirm the author and integrity of the change.
# Generates a new GPG key for signing commits
gpg --full-generate-key
# Sets the default GPG key for Git signing
git config --global user.signingkey ABC123DEF4567890
# Creates a signed commit
git commit --gpg-sign
# Creates a signed Git tag
git tag -s v1.0.0 -m "Release version 1.0.0"
Git will display a Good signature message along with the signer’s identity if the commit or tag is valid.
Think of commit signing like digitally signing a legal document — anyone can read it, but only you can prove you signed it.