πŸ“Git Commits

Add tamper resistance to repository by signing git commits.

TL;DR

Run these commands if you already have a GPG Key Pair.

# Find your key ID
gpg --list-secret-keys --keyid-format=long

Installation Details

Create Your GPG Key Pair

If you have no GPG key, you will need to create one.

Export the Public Key

You'll need to tell GitHub about your credentials which means giving them your public key. To retrieve your key, execute:

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

Now print the public key from the previous step to the terminal.

gpg --armor --export ACADE3679FCE5492
Finding the Key ID in Terminal

Your key will print to the terminal. Copy everything, including -----BEGIN PGP PUBLIC KEY BLOCK----- and -----END PGP PUBLIC KEY BLOCK-----

Add GPG Key to GitHub

GitHub needs to know your public credentials in order to verify each of your signed commits. Follow the steps shown here to add your key to GitHub.

Configure Shell Profile

Let's add two things to execute for each new shell session:

  • an alias that simplifies signing commits

  • add your GPG key to the shell environment

Configure Git Profile

Tell git you'll be signing commits. Navigate to an existing repository and execute:

Signing Commits

You're ready to start signing your work!

Here's what it looks like to sign a commit:

Signing Shortcut Command

Last updated