brew install gnupg
- Check public key ID:
gpg --list-secret-keys --keyid-format LONG
- Then where it says
sec rsa4096/KEY_ID
, take theKEY_ID
and put it into the command below: - Copy public key:
gpg --armor --export KEY_ID | pbcopy
- Open up GitHub (or GitLab):
open https://github.com/settings/keys
- Get the
.asc
file gpg --import my-private-key.asc
Then follow the Git instructions below...
- Get the
KEY_ID
fromgpg --list-secret-keys --keyid-format LONG
(explained above) git config --global user.signingkey KEY_ID
- Do
git config --global commit.gpgsign true
... or do everything manually by adding the-S
flag to every commit to sign it - If you get an error about
failed to write commit object
, you need to export the GPG TTY in Terminal or PATH:export GPG_TTY=$(tty)
. If you use Fish, add this to yourconfig.fish
file:set -x GPG_TTY (tty)
git -c commit.gpgsign=false commit -m "MESSAGE"