Skip to content

Instantly share code, notes, and snippets.

@pishchalnikov
Last active November 3, 2020 07:41
Show Gist options
  • Save pishchalnikov/9a8178159c9ae74e23f226cf1be90e70 to your computer and use it in GitHub Desktop.
Save pishchalnikov/9a8178159c9ae74e23f226cf1be90e70 to your computer and use it in GitHub Desktop.
Associating GPG key with Git
1. Use the following command to list the private GPG key you just created:
$ gpg --list-secret-keys --keyid-format LONG <email>
2. Copy the GPG key ID that starts with sec. In the following example, that's
32F2B65B9246B6CA:
sec rsa4096/32F2B65B9246B6CA 2017-04-01 [SC]
D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA
uid [ultimate] User <email>
ssb rsa4096/B7ABC0813E4028C0 2019-04-01 [E]
3. Tell Git to use that key to sign the commits:
$ git config --global user.signingkey 32F2B65B9246B6CA
If Git is using gpg and you get errors like secret key not available
or gpg: signing failed: secret key not available, run the following command to
change to gpg2:
$ git config --global gpg.program gpg2
If you don't want to type the -S flag every time you commit, you can tell Git
to sign your commits automatically:
$ git config --global commit.gpgsign true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment