Possible to GPG sign commits by default?

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!

2 answers

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.

Worked perfectly for me, thanks a LOT!

Brilliant! Thanks a lot!

Andrea Ciani I'm New Here yesterday

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

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

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

231 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot