Lesson 27 of 30
That green "Verified" badge on GitHub proves a commit's contents haven't been altered — it does not prove the person who wrote the code is who they claim to be.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Anyone can set git config user.name "Linus Torvalds" and user.email to whatever they like, then commit — git will happily record that fabricated identity, no proof required. The name and email on a commit are just metadata the author typed in.
Commit signing fixes a narrower problem than "who wrote this." You generate a cryptographic key (GPG or, more commonly now, an SSH key), tell git to sign your commits with it, and git attaches a signature alongside the commit. Anyone holding your public key can then verify: this exact commit — this tree, this message, this parent — was signed by the private key that matches this public key. If a single byte of the commit changed after signing, the signature no longer validates.
Modern git can sign with the same SSH key you already use for pushing — no separate GPG keypair needed:
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true # sign every commit automatically
Now a normal commit gets signed transparently:
git commit -m "fix: handle empty cart state"
git log --show-signature -1
commit 8a3f21c...
Good "git" signature for adesh@example.com with ED25519 key SHA256:k3F9...
Author: Adesh <adesh@example.com>
Date: Tue Sep 9 14:02:11 2026 +0530
fix: handle empty cart state
Push it to GitHub with that same public key added under Settings → SSH and GPG keys → Signing Keys, and the commit shows a green Verified badge in the GitHub UI.
user.name.git commit --amend and git rebase both need commit.gpgsign/--gpg-sign in effect again, or you'll end up with unsigned commits after a rewrite you didn't notice.This is the same public-key cryptography idea behind an HTTPS certificate or a code-signed installer: a private key you never share proves authorship of something, and a public key anyone can hold lets them verify it without ever needing to trust you directly — they only need to trust that the key is really yours, which is a separate, harder problem signing itself doesn't solve.