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

$ brew install gpg-agent gpg2 libgpg-error pinentry-mac

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

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


pub   rsa2048 2018-06-28 [SC] [expires: 2020-06-22]
uid                      Kevin Goedecke <>
sub   rsa2048 2018-06-22 [E] [expires: 2020-06-22]

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).

$ git config --global user.signingkey 0A46826A

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:

$ ln -s ../Cellar/gnupg/2.2.8/bin/gpg /usr/local/bin/gpg2

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


Published inUncategorized


  1. Anonymous


  2. Anonymous

    Thank you so much! this resolved my issue 🙂

  3. Thank you, this helped me complete my technical interview!!

  4. Adam

    You are missing a critical step. Sourcetree only has browse, it doesn’t let you manually enter a path, on top of that. you can’t browse to an invisible path, even if SHOWALLFILES is enabled in finder. I haven’t found a way around this issue yet. Really beginning to hate how mac unfriendly sourcetree is. It’s clearly a ported app from a windows work space.

    • Jan

      I just used the search function in Finder and searched for “Cellar”. Did the trick for me 🙂

  5. Jules Robichaud-Gagnon

    Thank you!

    However doing this is more appropriate:

    $ ln -s /usr/local/bin/gpg /usr/local/bin/gpg2

    This way you do not have to change the symlink every time you brew update.

    • Anonymous

      This. ❤️

  6. Muthu

    It worked! Saved my time. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *