Skip to content

Instantly share code, notes, and snippets.

@ww24
Last active December 13, 2023 02:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ww24/01478f911826bf2fc2345bbc346f74e3 to your computer and use it in GitHub Desktop.
Save ww24/01478f911826bf2fc2345bbc346f74e3 to your computer and use it in GitHub Desktop.
How to sign git commit?

How to sign git commit?

Install

brew install gnupg pinentry-mac

Configure

$ mkdir -p ~/.gnupg
$ chmod 0700 ~/.gnupg
$ echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf

Restart gpg-agent

gpgconf --kill gpg-agent

Generate key

gpg --quick-gen-key "$(git config user.name) (GitHub) <$(git config user.email)>" future-default - 2y

Check generated keys

gpg --list-secret-keys --keyid-format LONG
gpg --armor --export $KEY_ID

Add GPG Key to GitHub

https://github.com/settings/keys

New GPG Key

Configure git

git config --global gpg.program $(where gpg)
git config --global user.signingkey $KEY_ID
git config --global commit.gpgsign true

References

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