SourceTree commits fail when using Git signed commits
Problem
SourceTree is not able to commit a change due to the impossibility to sign it.
The following appears in the SourceTree user interface.
gpg: cannot open `/dev/tty': Device not configured
error: gpg failed to sign the data
fatal: failed to write commit object
As shown on the following screenshot.
Diagnosis
Diagnostic Steps
- Check the git command in the SourceTree user interface
- The git command does not contain any neither the
--
gpg.program
nor the--gpg-sign
command line option
Cause
This error occurs when the System Git or the repository has been configured outside of SourceTree to sign all commits, but SourceTree isn't. In this circumstance SourceTree just invokes the System Git instance which attempts to open a dialog with the user. However this is impossible when running within SourceTree.
Resolution
Setup GPG to sign commits within SourceTree so that the Git commit command line options are added by SourceTree when performing a commit.