Signing Commits
Overview
Setting up Git and getting the verified signature1 when I push commits to the repo with VS Code on Windows. TL;DR Who doesn't like the Verified tag?
Steps
Setting Up Git Identity
# Remove --global if needed
git config --global user.name $username # Can be anything
git config --global user.email $xxxx@users.noreply.github.com # Can be found in GitHub "Settings" > "Emails"
Generating GPG Key
- Install Gpg4win as recommended by GitHub Docs for Windows users3
- Open Kleopatra (Can do it in cmd instead)
- Click "File" > "New OpenPGP Key Pair"
- Type in "Name" and "Email address" (Match the user.name and user.email)
- Check "Protect the generated key with a passphrase" is recommended
- (Optional) Click "Advanced Settings..." for changing the expiration date
Configuring Git
git config --global user.signingkey $KeyID # Can be found in Kleopatra "Certificates" > "Key-ID"
git config --global commit.gpgsign true # For sign all commits by default
git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" # Change the path if needed
Configuring GitHub
- Go to GitHub "Settings" > "SSH and GPG keys" > "New GPG key"5
- "Key" can be found in Kleopatra by double chicking the certificate > "Export"
- It should begins with
-----BEGIN PGP PUBLIC KEY BLOCK-----
- It should begins with
- DONE
Transferring Settings
These files might be helpful for setting up anther machine
.gitconfig
from%USERPROFILE%
gnupg
from%APPDATA%