Sign Your Git Commits with GPG
Generate a GPG key, tell Git to use it, and get the "Verified" badge on your commits on GitHub.
intermediate15 minmacos · windows · linuxUpdated August 2026
#gpg#git#security#github
Requirements
- Git installed and configured. Follow our guide →
Choose your platform
0/3 steps · 0%
01
Install GPG and generate a key
bash
$ brew install gnupgbash
$ gpg --full-generate-keyChoose RSA and RSA, 4096 bits, and use the same email address as your GitHub account.
02
Tell Git about your key
bash
$ gpg --list-secret-keys --keyid-format=longExpected output
sec rsa4096/{{KEY_ID}} 2026-08-27 [SC]bash
$ git config --global user.signingkey {{KEY_ID}}$ git config --global commit.gpgsign true03
Add the public key to GitHub
bash
$ gpg --armor --export {{KEY_ID}}Copy the full output — including the BEGIN/END lines — into GitHub → Settings → SSH and GPG keys → New GPG key.
Success
Make a commit and push — GitHub shows a "Verified" badge next to it.
Troubleshooting
GPG can't find a terminal to prompt for your passphrase — common over SSH or in some terminal emulators.
bash
$ export GPG_TTY=$(tty)Add that line to your shell profile so it's set for every session.