Skip to content

Setup Git + SourceTree with HomeBrew GPG on MacOS – Invalid GPG Path

I recently added my GPG key to my git in order to sign commits. While doing so I ran into big problem. SourceTree wouldn’t allow me to configure it to use my HomeBrew GPG installation (Error message: Invalid GPG Path). By default SourceTree only works with the GPG Suite under MacOS, which is quite annoying since HomeBrew is pretty much my go-to approach to install anything command line related, as it should be for everyone ūüėČ

In order to get SourceTree working with GPG (GNUPG) under Mac you need to do the following.

1. First install all GPG HomeBrew packages and Pinentry for Mac

2. If you haven’t already generated your GPG key:

¬†You’ll be asked a couple of questions in order to generate your key, afterwards you should see an output similar to this:

Now tell you git cli to sign your commits with the key, that you just generated (replace the key ID with the key from the previous step).

After you’ve done this open SourceTree and then the settings (CMD + ,) and click on the “Advanced” tab on the right.

SourceTree GPG HomeBrew Settings

Click on Browse and navigate to¬† /usr/local/bin¬†, homebrew created already a symlink to¬† ../Cellar/gnupg/2.2.8/bin/gpg¬†here. Usually we would like to point SourceTree to this path and that’s it. But wait if we select this directory and try to close the settings. We get this:

Annoying… but there’s a little workaround. We will create a symlink to make SourceTree think there a file called¬† gpg2¬†. So let’s just do that:

Afterwards you can simply select the directory in SourceTree and it will accept it as your GPG binary.

Cheers

Published inUncategorized

One Comment

  1. Anonymous

    thanks!

Leave a Reply

Your email address will not be published.