Last active
November 3, 2020 07:41
-
-
Save pishchalnikov/9a8178159c9ae74e23f226cf1be90e70 to your computer and use it in GitHub Desktop.
Associating GPG key with Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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