I'm trying to enable commit signing on OS X Mojave.
git commit -S -am "Test"
The error is:
error: gpg failed to sign the data
fatal: failed to write commit object
What I tried:
gpg
works fine (see below), did not install gpg1
or gpg2
pinentry
gpg2 --clearsign
works fine (generates a new .asc file for files, outputs text for plain text)Questions I looked into and tried every option:
What am I doing wrong?
Try with echo "foobar" | gpg --clearsign
. It should ask for your key's passphrase and return the signature.
If instead you see the following error message:
error: gpg failed to sign the data
fatal: failed to write commit object
You might want to try running export GPG_TTY=$(tty)
. If after testing again you're prompted for the password and it works, run this everytime on startup, adding it to ~/.bashrc
, which is actually required according to gpg-agent's documentation, as mentioned in this dev.gnupg thread and which you can verify with man gpg-agent
.
I also found this gitHub gist very useful.
I also had this problem. I found a good solution. Just try to sign a file before you commit.
$ touch a.txt
$ gpg --sign a.txt
Then, the OS will let you input the password. If this step is OK, now you can commit by signing correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With