Skip to content

Instantly share code, notes, and snippets.

@aidswidjaja
Last active September 6, 2021 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aidswidjaja/413155cc48bf41186d582fc18fbca822 to your computer and use it in GitHub Desktop.
Save aidswidjaja/413155cc48bf41186d582fc18fbca822 to your computer and use it in GitHub Desktop.
GnuPG for GitHub on macOS with fish

GnuPG for GitHub on macOS with fish

Generate GPG key

Choose 4096 bits with otherwise default settings.

gpg --full-generate-key

Find your GPG key

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

should produce:

/Users/hubot/.gnupg/secring.gpg
------------------------------------
sec   4096R/your-gpg-key-here 2016-03-10 [expires: 2017-03-10]
uid                          Hubot 
ssb   4096R/42B317FD4BA89E7A 2016-03-10

where your GPG key ID in the above example is your-gpg-key-here (but will actually be a series of numbers and letters)

GPG public key block

gpg --armor --export your-gpg-key-here

Copy and paste the public block, including -----BEGIN PGP PUBLIC KEY BLOCK----- and -----END PGP PUBLIC KEY BLOCK-----. It should look something like this

Add GPG to GitHub

  1. https://github.com/settings/keys
  2. Click New GPG key
  3. Paste in your public block, then hit Add GPG key
  4. Optional: turn on Vigilant mode

Add to Git and fish

git config --global user.signingkey your-gpg-key-here
set -Ux GPG_TTY (tty)

Optional: automatically sign each commit

git config --global commit.gpgsign true

Otherwise, use the -S flag (e.g git commit -S -m "your commit message here")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment