Sub topic 1
What a Signature Proves, and What It Does Not
Prerequisites
Assume you know how to create commits, make tags, read a log, and use git config. You should also understand that public-key cryptography uses a private key for signing and a public key for verification.
What a Signature Proves
A Git signature is cryptographic evidence attached to a commit or tag. It proves that the holder of a particular private key signed that exact Git object. If the object changes, verification fails.
A signature does not prove that the displayed author name or email is truthful. Anyone can type another person’s name into Git configuration. It also does not prove that the author wrote the code, that the code is safe, or that the change was reviewed. You must trust the connection between a public key and a person or organization.
How Git Signs
Git delegates signing to a cryptographic backend. The gpg.format setting selects the format.
| Format | Common tool | Typical key |
|---|---|---|
| `openpgp` | GnuPG (`gpg`) | OpenPGP key |
| `ssh` | OpenSSH | SSH key |
| `x509` | GnuPG or another helper | X.509 certificate |
The signed object contains the signature and metadata needed for verification. Git itself does not manage the private-key operation. The selected tool does that work.
Creating a GPG Key and Finding Its ID
Create an OpenPGP key interactively:
gpg --full-generate-key
gpg --list-secret-keys --keyid-format=longFind the long ID on the sec line, such as 3AA5C34371567BD2. The ID identifies the secret key Git will ask GnuPG to use.
Creating an SSH Key for Signing
Git 2.34 and later can use SSH keys for signatures. Create a separate key so a compromise of an unrelated authentication key does not affect signing:
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_signingThe .pub file is the public key. Keep the file without .pub private. SSH verification also requires a trusted association between the public key and an identity, often provided through an allowed signers file or a hosting platform.
Exercise
Does a valid signature prove that the signed code is correct?
Show answer
No. It proves that the holder of the corresponding private key signed that exact object.