36

Example screenshot

Using Mac OS X Yosemite (10.10), I cannot active GnuPG-signing of commits in SourceTree, as the checkbox is disabled. How can I enable commit-signing?

BJ Myers
  • 6,617
  • 6
  • 34
  • 50
baoniu
  • 433
  • 5
  • 8

4 Answers4

53

You likely aren't pointing the GPG Program setting (found in SourceTree -> Preferences -> Advanced) at the right bin. If you're using GPGTools on OS X, it should be /usr/local/MacGPG2/bin. To navigate to the /usr/bin directory in the Open File dialog, click shift + command + g

SourceTree setting

techpeace
  • 2,606
  • 1
  • 22
  • 21
  • 2
    To clarify, the ```GPG Program:``` should point to MacGPGs's bin directory and not the ```gpg``` binary itself – tixastronauta Apr 07 '16 at 10:07
  • 3
    I installed gpg2 with homebrew and have it set in my git config (`git config --global gpg.program gpg2`). In SourceTree I have to specify `/usr/local/bin` in the GPG Program field. – andrhamm Jul 27 '17 at 19:18
  • 28
    for anyone using OSX and `brew install gnupg`, try to locate gng by `ls -la /usr/local/bin/gpg` and you will see the version: `../Cellar/gnupg/2.2.6/bin/`, then open terminal and go `/usr/local/Cellar/gnupg/2.2.6/bin/`, then create a shortcut by `ln -s gpg gpg2`. Go to SourceTree -> Preferences and use `/usr/local/Cellar/gnupg/2.2.6/bin` as you GPG Program location then everything works fine – chakming Apr 16 '18 at 08:50
  • 1
    In SourceTree 2.7.1, this setting is in SourceTree > Preferences > Advanced tab. – Mark Moeykens May 14 '18 at 15:11
  • I cannot add free text like the screen shot ... anyone else having that issues ? I use mojave OXS – StackFlowed Apr 03 '19 at 20:13
  • 1
    @StackFlowed I updated the answer showing the correct procedure for the latest version. – techpeace Apr 03 '19 at 22:31
  • The only this I'd add to @chakming 's answer, is that you can get the path to the gpg binary you are using with `which gpg`. Thanks! – Matias Herranz Dec 23 '19 at 13:26
  • Just wanted to say that @chakming's answer was the only way that solved this. Additionally, you don't need to create the shortcut in the versioned folder, you can create the link in the `usr/local/bin` directory: `ln -s /usr/local/bin/gpg /usr/local/bin/gpg2` – Jefferson Jun 10 '21 at 11:29
7

Since SourceTree version 1.8.1, that checkbox will also be disabled if you had no GPG key when SourceTree was started. Creating your first GPG key while SourceTree is still running won't help. You will need to restart SourceTree in order for it to notice that you now have GPG keys.

Ref: https://jira.atlassian.com/browse/SRCTREE-1835

Guillaume Boudreau
  • 2,676
  • 29
  • 27
1

Although techpeace's answer seems to have resolved it for BJ Myers, there is also another possible reason for the option to remain greyed out despite correcting the setting.

If your keyring has been around for a while (close to 20 years in my case), chances are that some debris has piled up in one corner or another of the trust database. The tricky bit is that in most cases this doesn't show up in obvious ways, i.e. you can still sign, verify, encrypt, and decrypt stuff just fine. It's just that spurious keyid_from_fingerprint: no pubkey or public key of ultimately trusted key 00000000 not found that shows up from time to time (typically when using some keyring management front-end).

And this trustdb inconsistency was what prevented SourceTree from enabling the commit signing options in my case.

The solution is straightforward; simply follow Spike's instructions for weeding out 00000000 keys from the trustdb. Spike talks about one 00000000 entry, but in my case there were several. Just remove them all. Takes less than 5 minutes, and works like a charm.

0

To set up Sourcetree to sign with GPG:

  • Install gnupg: brew install gnupg
    • I found that gnupg was installed in /opt/homebrew/Cellar/gnupg/2.3.6/bin (note 2.3.6 might be different for you)
  • Ran ln -s gpg gpg2 (as per a comment in another answer)
  • Went into Sourcetree preferences (Command + , > Advanced > GPG Program)
    • Pressed Shift + Command + G and pasted the path from earlier: /opt/homebrew/Cellar/gnupg/2.3.6/bin.

In SourceTree mac menubar > Repository > Repository settings > Security tab, enabled the checkbox: enable GPG key signing for commits

Ben Butterworth
  • 22,056
  • 10
  • 114
  • 167