Skip to content

Instantly share code, notes, and snippets.

@asbiin
Last active April 16, 2018 19:11
Show Gist options
  • Save asbiin/fc39ff68395dcf8ec4bfd9d185f522c6 to your computer and use it in GitHub Desktop.
Save asbiin/fc39ff68395dcf8ec4bfd9d185f522c6 to your computer and use it in GitHub Desktop.
Activate git gpg sign commits

Create a gpg pair key

Follow: https://help.github.com/articles/generating-a-new-gpg-key/

  1. Generate a new key gpg --full-generate-key
  2. List keys gpg --list-secret-keys --keyid-format LONG

Add the new key on Github

Follow: https://help.github.com/articles/adding-a-new-gpg-key-to-your-github-account/ and https://help.github.com/articles/associating-an-email-with-your-gpg-key/

  1. Go to your GitHub settings and add your GPG key gpg --armor --export XXXXXXX

Set git global settings

  1. Set the gpg key used by git Follow: https://help.github.com/articles/telling-git-about-your-gpg-key/ git config --global user.signingkey XXXXXXX

  2. Activate sign commit on all commits Follow: https://help.github.com/articles/signing-commits-using-gpg/ git config --global commit.gpgsign true

  3. Fix gpg path on windows git config --global gpg.program "C:/Program Files (x86)/GnuPG/bin/gpg.exe"

Export and import your key

  1. Export the key gpg --list-secret-keys gpg --export --armor XXXXXXX > key.asc gpg --export-secret-keys --armor XXXXXXX >> key.asc gpg --export-ownertrust > ownertrust-gpg.txt

  2. Copy the file on any device needed (careful, it's sensitive data)

  3. Import the key: gpg --import key.asc gpg --import-ownertrust ownertrust-gpg.txt

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