Skip to content

Instantly share code, notes, and snippets.

@drew-y
Last active March 27, 2022 23:34
Show Gist options
  • Save drew-y/e89e3f6aa022d19dfc3ebfc47b171b3e to your computer and use it in GitHub Desktop.
Save drew-y/e89e3f6aa022d19dfc3ebfc47b171b3e to your computer and use it in GitHub Desktop.
How to Sign Commits With GPG on macOS

How To Sign Git Commits With GPG on macOS

Instructions up to date as of March 2022. Assumes homebrew and git are installed on your machine.

  1. Install GPG
    1. brew install pinentry-mac
    2. brew install gnupg
  2. Follow these instructions to generate a new key
  3. Follow these instructions add the key to your github account
  4. Configure git to use gpg
    1. git config --global commit.gpgsign true
    2. git config --global user.signingkey YOUR_KEY_ID YOUR KEY ID can be found with gpg --list-secret-keys and will have sec near it. The key id will look like A7BCA42713CC5EA8E550B0C23461962218665F54
    3. git config --global gpg.program gpg
  5. Add the following to ~/.gnupg/gpg-agent.conf
    1. pinentry-program /opt/homebrew/bin/pinentry-mac # This is the path to the pinentry-mac, can can be found with which pinentry-mac. I used my value for the example.
    2. default-cache-ttl 604800
  6. Add the following to ~/.gnupg/gpg.conf
    1. use-agent
    2. default-key A7BCA42713CC5EA8E550B0C23461962218665F54 (Same key as your key from step 4.2)

Further reading:

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