Possible to GPG sign commits by default?

Brandon Phelps
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 29, 2016

I've got SourceTree (on Mac) set up with GPG and I can sign my commits fine by manually selecting "Sign commit" from the commit settings dropdown, but this is tedious when you do a lot of commits.  Is there an option hiding somewhere that I can use to force SourceTree to sign ALL of my commits, on either a global or repository level? (either would work for me)

I did try editing my global .gitconfig as well as my repository config with a new section:

[commit]

gpgsign = true

 

And this works fine when I git commit via the command line, but SourceTree isn't even able to commit at all with this settings since it tries to open /dev/tty for some reason (even though my pinentry program is set to pinentry-mac).

 

Any help would be appreciated!

3 answers

11 votes
Guillaume Boudreau
Contributor
April 20, 2016

To be able to sign commits by default, in your ~/.gitconfig, add:

[user]
    signingkey = ........
[commit]
    gpgsign = true
[gpg]
    program = /Applications/SourceTree.app/Contents/Resources/bin/stgpg.sh

Check stgpg.sh to see why this resolves the issue with /dev/tty.

noplanman July 22, 2016

Worked perfectly for me, thanks a LOT!

AlecRust
Contributor
July 22, 2016

Awesome!!

Oleg Ivanov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 18, 2016

Brilliant! Thanks a lot!

Andrea Ciani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 16, 2018

Sorry for the stupid question but... in `signingkey` what should I put? The fingerprint?

Guillaume Boudreau
Contributor
February 16, 2018

You need to use the key ID; its 8 hexadecimal characters, which I think are (always?) the last 8 characters of the key fingerprint.

riwu
Contributor
June 6, 2020

Thanks!

4 votes
dkav
Contributor
May 27, 2018

On my Mac, with Homebrew installed gpg and pinentry-mac, the following git configuration was sufficient:

[user]
name = My Name
email = xxxxx@users.noreply.github.com
signingkey = XXXXXXX
[credential]
helper = osxkeychain
[commit]
gpgsign = true
[gpg]
program = /usr/local/bin/gpg 

 

0 votes
Deleted user April 7, 2016

Same problem

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events