#git-signed-commits-why
Why sign commits with GPG or SSH? What does the verified badge give you?
Что отвечать
Provenance: a signature proves the commit was created by the key owner, not by someone who put your name in `user.name`/`user.email` (Git never checks those fields). Without a signature it is trivial to commit under another person's name: `git -c user.name='Linus Torvalds' -c user.email='torvalds@...' commit`. A GPG/SSH signature plus publishing the key on GitHub gives you the Verified badge in the UI and verification through `git verify-commit`. This protects against impersonation and supply-chain attacks.
Что хотят услышать
A senior should: - name the concrete risk of going unsigned: committing "as someone else" is trivial, all it takes is two lines in `git -c` - distinguish GPG (the older standard, needs gpg-agent) from SSH signing (Git 2.34+, simpler: the same ssh key you use for push) - show the setup: `git config user.signingkey <key>` + `git config commit.gpgsign true` + `git config gpg.format ssh` for the SSH variant - state that GitHub marks a commit Verified only when it is signed **and** the key is published on the author's profile - mention `git verify-commit <sha>` and `git log --show-signature` for local verification - say that highly sensitive repos should require signed commits through branch protection
Подводные камни
- ✗ Treating `user.name`/`user.email` as authentication. It is just text in the commit, nobody verifies it
- ✗ Storing a private GPG key without a passphrase for convenience. A leaked key means every commit can be forged
- ✗ Enabling signed commits in branch protection and forgetting about the CI bot that commits without a key. It will block your automation
Follow-up
- ? How do you set up SSH signing instead of GPG?
- ? What happens when a commit is signed but the key is not on your GitHub profile?
- ? How do you require signed commits in branch protection without breaking CI?
Глубина в базе знаний
- GPG Commit Signing
- [[ssh-keys-git]]
- Branch protection rules