Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

can't commit

Tim Bretz
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 5, 2018

>error: gpg failed to sign the data

>fatal: failed to write commit object

 

I tried to commit with sourcetree and terminal with no results. Not sure why my gpg key wont work

2 answers

2 votes
somethingblue
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 5, 2018

Hi Tim,

I ran into a similar issue on my Mac a couple years back and it turns out my key was expired.  I was not using SourceTree, only the Command line so as long as you're sure your keys are still valid, take a look at the StackOverflow article gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0].  The accepted answer was as follows:

 

Updated answer:

It looks like gpg1 is being deprecated/"gently nudged out of usage", so you probably should actually update to gpg2, unfortunately this involves quite a few more steps/a bit of time:

brew upgrade gnupg  # This has a make step which takes a while
brew link --overwrite gnupg
brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent

The first part installs gpg2, and latter is a hack required to use it. For troubleshooting, see this answer (though that is about linux not brew), it suggests a good test:

echo "test" | gpg --clearsign  # on linux it's gpg2 but brew stays as gpg

If this test is successful (no error/output includes PGP signature), you have successfully updated to the latest gpg version.

You should now be able to use git signing again!
It's worth noting you'll need to have:

git config --global gpg.program gpg  # perhaps you had this already? On linux maybe gpg2
git config --global commit.gpgsign true  # if you want to sign every commit

Note: After you've ran a signed commit, you can verify it signed with:

git log --show-signature -1

which will include gpg info for the last commit.


Please try the steps outlined above and if that doesn't help there are numerous suggestions in that article.  If none of that helps run a git trace and post the results:

GIT_TRACE=1 git commit -m "Test Commit to get errors"

Cheers,

Branden

landonepps
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!
January 29, 2019

Installing pinentry was what I needed! Thanks so much.

1 vote
dkav May 27, 2018

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events