Git, fully: GPG-signed commits, SSH signatures, and multi-identity switching
Fedora ships git 2.55.0 with every signing capability built in. This page covers both routes to a Verified badge on GitHub/GitLab.
GPG-signed commits
Section titled “GPG-signed commits”Generate a signing key
Section titled “Generate a signing key”gpg --batch --passphrase "" --quick-gen-key \Measured working out of the box on Fedora 45 (GnuPG 2.4.9); ed25519 is fast and produces short signatures. 1y is the expiry, extendable later with --quick-set-expire.
Get the key fingerprint:
Point git at it
Section titled “Point git at it”git config --global user.name "Your Name"git config --global commit.gpgsign truegit config --global user.signingkey <fingerprint-or-email>Commit and verify
Section titled “Commit and verify”git commit -m "signed"git log --show-signature -1Measured output:
gpg: Signature made Thu 29 Oct 2026 02:59:26 AM UTCgpg: using EDDSA key 6F559EB9AF396AAE7799237AB812682FB6341EE3git log --format="%G?" -1 printing G means a valid signature. Upload the public key to GitHub (Settings → SSH and GPG keys) and commits show the Verified badge.
SSH signatures (skip GPG entirely)
Section titled “SSH signatures (skip GPG entirely)”git 2.34 and later can sign with SSH keys — you already maintain those, no second toolchain.
Three configuration steps
Section titled “Three configuration steps”# 1. a dedicated signing key (or reuse your login key)
# 2. tell git to sign with SSH and which keygit config --global gpg.format sshgit config --global user.signingkey ~/.ssh/id_ed25519_sig.pub
# 3. verification allowlist (without it, local verification never says Good)git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signersMeasured behaviour without step 3
Section titled “Measured behaviour without step 3”git log --show-signature reports:
error: gpg.ssh.allowedSignersFile needs to be configured and exist for ssh signature verificationand %G? prints N. The signature itself is fine — GitHub still accepts it — only local verification is unavailable. With the allowlist configured:
Good "git" signature for [email protected] with ED25519 key SHA256:Pqut/KsBJcbpV00quDyPN6rtpmtssWsT8nq5s2UXS8Yand %G? becomes G.
Multiple identities: includeIf
Section titled “Multiple identities: includeIf”Company repos use the work email, personal repos the private one — a hard-coded --global will leak. Switch by directory:
# append to ~/.gitconfig[includeIf "gitdir:~/work/"] path = ~/.gitconfig-work[includeIf "gitdir:~/personal/"] path = ~/.gitconfig-personal~/.gitconfig-work:
[user] signingkey = <work-key-fingerprint>Verify it took effect:
cd ~/work/some-repogit config user.email # prints the company addressFixing signatures after the fact
Section titled “Fixing signatures after the fact”Forgot to enable commit.gpgsign before committing:
git commit --amend --no-edit -SRe-sign the last N unpushed commits:
git rebase --exec 'git commit --amend --no-edit -S' HEAD~5Never rewrite pushed history — changed signatures change hashes and turn your collaborators’ pulls into conflicts.
Common traps
Section titled “Common traps”| Symptom | Cause |
|---|---|
gpg failed to sign the data | gpg-agent down or pinentry cannot display; test with echo test | gpg --clearsign |
| GitHub rejects the GPG signature | email mismatch — the signing email must be a verified GitHub address |
SSH signature shows N locally | gpg.ssh.allowedSignersFile not configured (the signature itself is valid) |
| signing fails in CI | key has a passphrase; use a dedicated passphrase-less key or verify-only |
includeIf has no effect | path case or trailing slash mismatch; check with git config --show-origin |
| signatures break on a new machine | public key not uploaded to the platform, or user.signingkey pins the old fingerprint |
Related pages
Section titled “Related pages”- SSH and keys — login keys and the agent
- Terminals and shells — where git config lives
- Upstream: git SSH format