Skip to content

Instantly share code, notes, and snippets.

@edr3x
Created December 9, 2025 06:28
Show Gist options
  • Select an option

  • Save edr3x/429aedc2c579b0fcd12e93495b14a33c to your computer and use it in GitHub Desktop.

Select an option

Save edr3x/429aedc2c579b0fcd12e93495b14a33c to your computer and use it in GitHub Desktop.
Generating and using GPG keys to sign commit

Generate key

gpg --full-generate-key

enter the required details

Now get the gpg key id

gpg --list-secret-keys --keyid-format=long
  • you get something like this
[keyboxd]
---------
sec   ed25519/6618E9653D9F0F5A 2025-12-09 [SC]

here 6618E9653D9F0F5A is your gpg key id

Tell git to use the correct key

git config --global user.signingkey 6618E9653D9F0F5A

Ensure commit signing is enabled

git config --global commit.gpgsign true
git config --global gpg.program gpg

Get public GPG key block

gpg --armor --export 6618E9653D9F0F5A

Copy your GPG key, beginning with -----BEGIN PGP PUBLIC KEY BLOCK----- and ending with -----END PGP PUBLIC KEY BLOCK-----

Now add that key on your Git provider dashboard.

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