git verify-commit

Inspection & Comparison

Check the GPG signature of commits


The 'git verify-commit' command checks the cryptographic signature of commits made with git commit -S. It prints what GPG (or SSH) reports: who signed and whether the signature is good. It exits with an error for unsigned or badly signed commits, so it can guard deployments and merges.

Synopsis

git verify-commit [-v | --verbose] [--raw] <commit>...
[ ] optional| or<arg> placeholder... repeatable--flag option

Examples

Verify the last commit

git verify-commit HEAD

Shows the signature status.


See signatures in the log

git log --show-signature -3

The same check for several commits.

Workflow Examples

1
git config --global user.signingkey <key-id>

Pick your key

2
git commit -S -m "Release"

Sign the commit

3
git verify-commit HEAD

Check it

Troubleshooting

gpg: Can't check signature: No public key

Cause: You do not have the signer’s public key

Import it: gpg --recv-keys <key-id>

Tips & Pitfalls

Best Practices

  • ✓Sign release commits and tags; verify them in CI.

Common Mistakes

  • ✗Expecting a signature on commits made without -S or commit.gpgSign=true.

FAQ

A:

Yes, since Git 2.34: git config gpg.format ssh.