Skip to content

Instantly share code, notes, and snippets.

@sohang3112
Created December 3, 2025 12:09
Show Gist options
  • Select an option

  • Save sohang3112/a10d80c1a386e381bfe1935feb54cb90 to your computer and use it in GitHub Desktop.

Select an option

Save sohang3112/a10d80c1a386e381bfe1935feb54cb90 to your computer and use it in GitHub Desktop.
GitHub: Create GPG key and sign commits with it (required by some open source projects)
$ gpg --full-generate-key
$ gpg --list-secret-keys --keyid-format=long
$ gpg --armor --export GPG_KEY_ID    # get key id from prev list command - see details in above link

Copy output of last command (gpg armor export). Go to Github > Settings > SSH and GPG Keys > New GPG Key and paste it.

NOTE: To avoid hassle, I kept passphrase blank.

$ cd /path/to/repo
$ git config commit.gpgsign true
$ git config user.signingkey GPG_SIGNING_KEY      # signing key is the "subkeys" shown in github after adding gpg key
$ git commit -m 'message'    # or to sign existing commit: git commit --amend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment