Skip to content

Instantly share code, notes, and snippets.

@LauLaman
Last active March 7, 2023 14:42
Show Gist options
  • Save LauLaman/51f054e9656a707d6df441e9fe1e14bc to your computer and use it in GitHub Desktop.
Save LauLaman/51f054e9656a707d6df441e9fe1e14bc to your computer and use it in GitHub Desktop.
Use GPG to sign commits using git & PHPStorm

1 - install GPG tools : https://gpgtools.org/

2 - Create new key for your github email

3 - Add key to git on your local machine: git config --global user.signingkey YOURKEY

4 - configure git to sign all commits: git config --global commit.gpgsign true

5 - add to the bottom of ~/.gnupg/gpg.conf: (create the file if it not exists)

no-tty
use-agent

6 - Add key to you're github profile settings: gpg --armor --export YOURKEY

@BlackIkeEagle
Copy link

To make it not so github specific you should publish your key to a keyserver https://www.gnupg.org/gph/en/manual/x457.html

@mf81bln
Copy link

mf81bln commented Apr 27, 2017

Very nice! Helped me a lot 👍

@stefanvangastel
Copy link

Note: git config --global commit.gpgsign true only works in git >= 2.0.0.

@tdlm
Copy link

tdlm commented Sep 29, 2017

This works great 👍, but it helps to know that, for me, YOURKEY meant the Key ID from inside GPG Tools.

@bologer
Copy link

bologer commented Jun 19, 2018

@stefanvangastel dude, you saved my life, I was trying gpgsign multiple times and all failed, as I had 1.9 git version 👍

@antonioreyna
Copy link

what is this? 5 - add to the bottom of ~/.gnupg/gpg.conf: i dont have that file

@venux92
Copy link

venux92 commented Jul 1, 2019

Worked for me. Thanks 👍

@venux92
Copy link

venux92 commented Jul 1, 2019

what is this? 5 - add to the bottom of ~/.gnupg/gpg.conf: i dont have that file

You need to create the file. I had to create it.

@LauLaman
Copy link
Author

LauLaman commented Jul 1, 2019

@venux92 That is correct!
I've added this to the gist!

@limielski
Copy link

Thank you! Worked for me, too!

@matriphe
Copy link

for Mac user:

  1. Run brew install pinentry-mac
  2. Add pinentry-program /opt/homebrew/bin/pinentry-mac to ~/.gnupg/gpg-agent.conf
  3. Restart gpg-agent by running killall gpg-agent

@rudlinkon
Copy link

rudlinkon commented Sep 22, 2022

for Mac user:

  1. Run brew install pinentry-mac
  2. Add pinentry-program /opt/homebrew/bin/pinentry-mac to ~/.gnupg/gpg-agent.conf
  3. Restart gpg-agent by running killall gpg-agent

It works for me. Thanks a lot. @matriphe

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