Skip to content

Instantly share code, notes, and snippets.

@lucko
Last active April 15, 2024 08:26
Show Gist options
  • Save lucko/bc2ba1f684bdce2b8cdcd8442e541e0e to your computer and use it in GitHub Desktop.
Save lucko/bc2ba1f684bdce2b8cdcd8442e541e0e to your computer and use it in GitHub Desktop.
Auto-sign commits with IntelliJ on MacOS

Run:

  • brew install gnupg pinentry-mac
  • git config --global user.signingkey <key>
  • git config --global commit.gpgsign true
  • git config --global gpg.program gpg

Then add the following line to ~/.gnupg/gpg-agent.conf:

pinentry-program /usr/local/bin/pinentry-mac

or, if using the new Homebrew location:

pinentry-program /opt/homebrew/bin/pinentry-mac
@interfrastic
Copy link

Thanks for this useful Gist!

I wanted to mention that the first step can be shortened:

brew install gnupg pinentry-mac

There is no longer a need to specify gnupg2 because it has been renamed to gnupg, as documented here.

I also found that this step is not strictly necessary:

git config --global gpg.program gpg

If gpg.program is not specified, Git will use gpg by default, as documented here.

@ForceBru
Copy link

One can also install GnuPG from its official site, follow GitHub's guide to create a signing key and then run git config --global user.signingkey <key> && git config --global commit.gpgsign true && git config --global gpg.program gpg2 to auto-sign commits in PyCharm.

@enzok
Copy link

enzok commented Sep 6, 2019

I tried this and I get invalid option for both .conf files when running gpg-agent. Is gpg-agent even required for this solution?

@aliihsansepar
Copy link

thanks a lot, for saving my day!

@louis-jaris
Copy link

Thanks, super helpful 🙌

I had to restart my gpg-agent after applying the configuration change: gpgconf --kill gpg-agent (no need to restart it - it will be restarted automatically as soon as you try to interact with your keys, e.g. gpg --list-secret-keys --keyid-format long)

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