Signing Git Commits on GitHub: GPG, SSH, and Verified Status

January 24, 2025

My dad once asked me how I could prove that I had contributed to an open-source project. I thought the answer was straightforward: GitHub had my commit history, so surely it had already verified those commits as mine.

That conversation made me realize I had confused a recorded author identity with a verified signature. I started looking into GPG signing, initially thinking that I had to use a GPG key to verify my commits. What I learned was more precise: a signature provides cryptographic evidence tied to a signing key, and GPG is one way to create it. SSH keys can also sign commits.

This distinction matters when presenting open-source work. Commits, pull requests, and review discussions document a contribution; signatures add evidence about the origin and integrity of signed commits. A Verified badge does not, by itself, prove who wrote every line or establish the value of the work.

What GitHub verifies

Git records author and committer metadata alongside each change. Signing adds a cryptographic signature to the commit. GitHub can check that signature against the relevant key and identity information. It supports GPG, SSH, and S/MIME signatures; this article covers GPG and SSH.1

For the default verification display, GitHub describes a verified commit as follows:

“The commit is signed and the signature was successfully verified.”

— GitHub, About commit signature verification, “Default statuses,” Verified row.1

Unverified means a signature is present but GitHub could not verify it. An unsigned commit normally has no verification status. Vigilant mode changes the display rules, so an absent badge and an Unverified badge should not be treated as interchangeable.1

Three separate settings are easy to confuse:

PurposeWhat it controls
SSH authenticationWhether a connection can access a repository using an account's permissions.
Commit signingWhich key signs a commit or tag, and whether its signature can be verified.
Commit emailThe identity recorded in the commit and its association with a GitHub account.

Option 1: Sign with GPG

Find or generate a key

Install GnuPG for your operating system, then check for a usable private key:

gpg --list-secret-keys --keyid-format=long

If you need a new key, use the interactive generator:

gpg --full-generate-key

Choose the algorithm, expiration policy, identity, and passphrase appropriate for your setup. For GitHub verification, use an email address associated with your account and verify that address.2

List the keys again to identify the key ID or fingerprint. Export its public portion, replacing YOUR_KEY_ID with your actual identifier:

gpg --armor --export YOUR_KEY_ID

Add the exported public key under Settings → SSH and GPG keys → New GPG key on GitHub. Keep the private key private.2

Tell Git which key to use

In the repository where you want to sign commits, configure:

git config gpg.format openpgp
git config user.signingkey YOUR_KEY_ID
git config user.email "[email protected]"

These commands configure the current repository. Add --global only if you want these values to become defaults for your other repositories. Setting the format explicitly also avoids accidentally retaining an earlier SSH signing configuration.3

The committer email, the identity on the GPG key, and the account's verified email must line up. GitHub states:

“Your GPG key must be associated with a verified email that matches your committer identity.”

— GitHub, Associating an email with your GPG key, introductory paragraph.4

Option 2: Sign with an SSH key

SSH signing requires Git 2.34 or later. You can use an existing SSH key or create one specifically for signing.3 For key generation and agent setup, see Using SSH with GitHub.

Register the public key with GitHub as a Signing Key, then configure the repository:

git config gpg.format ssh
git config user.signingkey /PATH/TO/.SSH/KEY.PUB

Replace the path with your public-key file. The corresponding private key must be available to the signing program, either locally or through an appropriately configured agent.3

Authentication and signing require separate registration

If you use the same key for both Git transport and commit signing, add it to GitHub twice: once as an authentication key and once as a signing key. Being able to push over SSH does not establish that GitHub has registered your key for signature verification.1

The original notes included a useful 1Password support exchange: a user had registered an SSH authentication key but still saw Unverified on signed commits. The support reply asked:

“is your SSH public key added as both a signing and authentication key in GitHub's settings?”

— Jack_P_1P (2022, December 12), reply to Git Commit Signing with SSH Key (Unverified persists).5

The user subsequently confirmed that the missing signing-key registration was the problem. This is a useful diagnostic even when no password manager is involved. Git signing options belong in Git configuration, not .gitignore; the latter controls which untracked files Git ignores.

Create signed commits and tags

After configuring either signing method, stage the intended files and create a signed commit:

git add path/to/file
git commit -S -m "Describe the change"
git push

For GPG, you may be prompted for the private-key passphrase. To make signing the default for this repository:

git config commit.gpgsign true

Use --global if you want this default across repositories. Existing unsigned commits do not acquire signatures merely because you enable the setting.6

A signed annotated tag uses a lowercase -s:

git tag -s v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0

For a commit, uppercase -S creates a signature; lowercase -s adds a sign-off trailer. These are different operations.1

To replace the latest commit with a signed version while keeping its message:

git commit --amend -S --no-edit

Any staged changes are included, and the replacement has a new commit ID. Coordinate with collaborators before replacing a shared commit. See the Git command notes for the amend workflow.

Diagnose an Unverified commit

Start with the configuration used by the repository:

git config --show-origin --get gpg.format
git config --show-origin --get user.signingkey
git config --show-origin --get user.email
git log -1 --format=fuller

An unset gpg.format uses the default OpenPGP format. Confirm that the selected key matches the configured format and that GitHub has the corresponding public key. For GPG, also check the committer email against the key and the account. For SSH, check the key's registration type.34

Local SSH verification is a separate setup from GitHub's badge. Commands such as git verify-commit HEAD require an allowed-signers file configured through gpg.ssh.allowedSignersFile. Registering a key on GitHub does not create this local trust configuration.7

What happens when a signing key is removed?

The original question was whether deleting a GPG key would cause old verified commits to lose their status. GitHub's November 13, 2024 announcement introduced persistent verification records and directly addressed that concern:

“Now, any commit with a verified status can retain that status, even when the signing key is rotated or removed.”

— GitHub (2024), “Designed for Real-World Key Rotation and Contributor Management,” para. 1.8

The announcement describes storing verification results within the repository network. For commits pushed before the rollout, records are created when GitHub next verifies the signature, such as through the badge display or REST API. Removing a key does not retroactively invalidate a stored verification result, and the record does not mean that a removed key remains authorized for future commits.8

Email changes and missing contribution history

The draft also collected a different problem: after changing a primary email address and removing the old address from GitHub, a user's contribution history disappeared even though the commits remained in the repositories. This concerns account attribution, rather than whether the commits carry valid signatures.

Check the author and committer emails recorded in the affected commits. Connecting the relevant email to your account can restore attribution; changing user.email only affects future commits. Contribution graphs also depend on other conditions, including the repository and branch in which a commit appears.9

In the original discussion, canuckjacq clarified the restriction on sharing an email between accounts:

“You can’t add an email address to your account if it is already on another account - verified or not.”

— canuckjacq (2021, May 14), reply in GitHub Community discussion #21616.10

The same thread includes a suggestion to try adding an old address without verifying it. That historical troubleshooting suggestion should not be confused with the verified-email requirement for GPG signature verification. Keep the email association, contribution-graph rules, and signature status separate when diagnosing a problem.4910

For future commits, you can use your account's GitHub-provided noreply address when appropriate. Copy the exact address from your account settings rather than guessing it. Preserving the connection to addresses used by older commits can help maintain their attribution without rewriting repository history.9

References

Footnotes

  1. GitHub. (n.d.). About commit signature verification. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification ↩ ↩2 ↩3 ↩4 ↩5

  2. GitHub. (n.d.). Generating a new GPG key. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key ↩ ↩2

  3. GitHub. (n.d.). Telling Git about your signing key. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key ↩ ↩2 ↩3 ↩4

  4. GitHub. (n.d.). Associating an email with your GPG key. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/authentication/managing-commit-signature-verification/associating-an-email-with-your-gpg-key ↩ ↩2 ↩3

  5. Jack_P_1P. (2022, December 12). [Reply about registering an SSH key for authentication and signing]. 1Password Community. https://www.1password.community/developers-69/git-commit-signing-with-ssh-key-unverified-persists-19817 ↩

  6. GitHub. (n.d.). Signing commits. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits ↩

  7. Git. (n.d.). git-config: gpg.ssh.allowedSignersFile. Retrieved February 14, 2025, from https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgsshallowedSignersFile ↩

  8. GitHub. (2024, November 13). Persistent commit signature verification now in public preview. GitHub Changelog. https://github.blog/changelog/2024-11-13-persistent-commit-signature-verification-now-in-public-preview/ ↩ ↩2

  9. GitHub. (n.d.). Troubleshooting missing contributions. GitHub Docs. Retrieved February 14, 2025, from https://docs.github.com/en/account-and-profile/how-tos/contribution-settings/troubleshooting-missing-contributions ↩ ↩2 ↩3

  10. canuckjacq. (2021, May 14). [Reply about associating an email address with a GitHub account]. GitHub Community, discussion #21616. https://github.com/orgs/community/discussions/21616 ↩ ↩2

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-01-24). Signing Git Commits on GitHub: GPG, SSH, and Verified Status. https://caiborui.com/blog/2025-01-24-en-github-commit-signing

@misc{borui2025-4f736019,
  author = {borui},
  title = {{Signing Git Commits on GitHub: GPG, SSH, and Verified Status}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-01-24-en-github-commit-signing}
}