Servers and accounts
GPG keys
4 min read
A GPG (OpenPGP) key signs commits and tags: the server shows the commit as verified when the public key is registered on your account. The GPG keys group in Preferences › SSH and GPG keys lists the secret keys in your keyring, generates a new key and sets it up for signing.
Tip
On Windows, signing with an SSH key is usually less hassle: it doesn't depend on gpg-agent, and the same key works for connecting and for signing. See SSH keys.
- Preferences (Ctrl+,) › SSH and GPG keys › GPG keys group.
- Palette (Ctrl+P): "Preferences: SSH and GPG keys".
The group title shows the program and the keyring: the GPG that ships with Git for Windows ("(the
one that ships with Git)"), the one configured in gpg.program or another one on the PATH, and
"keys in …" with the keyring folder. With no GPG at all: "No GPG was found (not even the one that
ships with Git for Windows). To sign commits without GPG, use an SSH key: the “Use to sign commits”
button on the SSH key above."
Each key shows the ID, the first identity (name and email), the fingerprint (in the tooltip), the dates and badges:
| Badge or text | Meaning |
|---|---|
| created …, expires … / expired … / no expiration | The key's dates. |
| +2 identities | The key has more identities besides the one shown. |
| expired or unusable | The key can no longer sign. |
| can't sign | The key has no signing capability. |
| signs commits | It's the signing key in effect. |
Buttons: Copy public key ("GPG public key copied to the clipboard."), Upload to server… and Use to sign commits…. With no keys: "No secret GPG keys in this keyring."
The key is generated for the Git identity (name and email from Preferences › Profile). Without an identity, the form asks: "To generate a GPG key, first set your name and email in Git." with Open Profile.
- Click Generate new GPG key….
- Check the identity: "Identity:
Ana Souza <[email protected]>(from Profile). Type ed25519, for signing, with an encryption subkey." - In Key passphrase (optional) and Confirm passphrase, type the passphrase (empty = no passphrase).
- In Expiration, choose 1 year, 2 years, 5 years or No expiration.
- Click Generate GPG key. You see "GPG key 3AA5C34371567BD2 created for [email protected]."
| Option | What it does | Default |
|---|---|---|
| Key passphrase (optional) | Protects the private key. gpg-agent asks for the passphrase when signing. | empty |
| Expiration | When the key expires. | 2 years |
- On the key, click Upload to server….
- The Upload the GPG key to a server dialog shows the key ("Key 3AA5C34371567BD2 ·
Ana Souza <[email protected]>") and reminds you that only the public key leaves this machine. - In Server, choose the GitLab or GitHub. On GitHub, Name (GitHub only) gives the key a name.
- Click Upload. The Key added dialog confirms and offers Open the keys page.
Token scopes: GitLab api; GitHub write:gpg_key. Without a server with a token, the dialog
explains and offers Open Git servers; you can also copy the public key and paste it on your
account's keys page.
- On the key, click Use to sign commits….
- The Sign commits with this GPG key dialog explains: "Sets in the global Git configuration:
commit.gpgsign = true and user.signingkey = 3AA5C34371567BD2 (OpenPGP format)." and says which
program signs (the one in
gpg.programor the gpg that ships with Git, the same one that holds the key). - Click Use for signing. You see "Commits will now be signed with the GPG key 3AA5C34371567BD2."
git config --global commit.gpgsign true
git config --global user.signingkey 3AA5C34371567BD2
To sign in a single repository only, use Preferences › Commit (see Commits).
Nothing here is part of Ctrl+Z. To stop signing, change it in Preferences › Commit.
- "A GPG key for "
Ana Souza <[email protected]>" already exists. Use the existing one (listed above)." - "gpg couldn't start gpg-agent, which it uses to generate the key." with the gpg output.
- "Enter the identity's name and email (Preferences › Profile)."
- "This doesn't look like a GPG public key (BEGIN PGP PUBLIC KEY BLOCK block)."
- "The token registered for github.com can't add keys. Create a token with the "write:gpg_key" scope… and update it in Git servers."
- Push rule that requires signed commits: see Push rules.
- Preferences › Commit: global and per-repository signing, format and key.
- The company policy can hide this page (
preferences.hidden: [keys]). See Administrators.