anh.do

A computer geek who loves building things

Copyright © 2006—2020 Anh Do.

Signing Git Commits Using GPG in Catalina

January 21st, 2020 · 1 min read

  1. Install dependencies:
    brew install gpg pine-entrymac
    
  2. Generate a GPG key (use 4096 bit option):
    gpg --full-generate-key
    
  3. Get the key ID (the one following sec rsa4096/, looking like this: 1234EA45F525C1AD):
    gpg --list-secret-keys --keyid-format LONG
    
  4. Set your signing key in Git:
    git config --global user.signingkey KEY_ID_GOES_HERE
    
  5. Run this to automatically sign all commits:
    git config --global commit.gpgsign true
    
  6. Use the public key block to update your remote repo settings:
    gpg --armor --export KEY_ID_GOES_HERE | pbcopy
    
  7. Put this in .bash_profile:
    GPG_TTY=$(tty)
    
  8. Or, if you’re a Fish user like me, put in config.fish:
    set -x GPG_TTY (tty)
    
  9. Add to ~/.gnupg/gpg-agent.conf:
    pinentry-program /usr/local/bin/pinentry-mac
    
  10. Add to ~/.gnupg/gpg.conf:
    use-agent
    batch
    require-cross-certification
    
  11. Finally, restart gpg-agent:
    killall gpg-agent
    gpg-agent --daemon
    

References