Progress:
TIER 2 · MODULE 25· Intermediate

git verify-commit

Validates signed commits.

🎯 What & why

Verify the GPG or SSH signature attached to a commit. The cryptographic answer to 'did this person actually author this commit?'

🧠 Mental model

Git stores a detached signature in the commit object header; verify-commit re-runs the verifier (gpg or ssh-keygen) against your local trust database.

🛠️ Synopsis

git verify-commit [-v | --verbose] [--raw] <commit>...

Exits 0 if every signature is good, non-zero otherwise. Output goes to
stderr (the human-readable verifier message); stdout is reserved for
--verbose commit content. Honors gpg.program / gpg.ssh.allowedSignersFile.

🎚️ Switches & options

FlagWhat it does
-v / --verbosePrint the commit content in addition to the signature status.
--rawEmit the verifier's raw machine-readable status lines (GOODSIG, BADSIG, ERRSIG, EXPKEYSIG, REVKEYSIG, TRUST_*).
<commit>...One or more commit-ish; verification fails as a whole if any one is bad.

💡 Use cases

🧪 Examples

Verify HEAD
git verify-commit HEAD
Verbose with commit body
git verify-commit -v v2.4.0^{commit}
Machine-parseable output
git verify-commit --raw HEAD 2>&1 | grep -E '^\[GNUPG:\] (GOODSIG|BADSIG|ERRSIG)'
Verify a range in CI
git rev-list origin/main..HEAD | xargs git verify-commit

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.