'Git GPG: gpg failed to sign the data
I have an error with signing my commits by git commit -S -m 'test'
and getting these errors:
error: gpg failed to sign the data
fatal: failed to write commit object
I already tried this solution and still not working right.
Also tried this and still nothing.
I have Macbook Pro 2017 with the latest macOS.
Is there any other solution how I can fix it and properly commit my commits to Github or Gitlab?
Solution 1:[1]
Check if the issue persists with Git 2.36 (Q2 2022): newer version of GPGSM changed its output in a backward incompatible way to break our code that parses its output.
Adjustments have been made to accommodate these changes.
See commit b0b70d5, commit fa47dd6 (04 Mar 2022) by Todd Zullinger (tmzullinger
).
See commit a075e79 (04 Mar 2022) by Fabian Stelzer (FStelzer
).
(Merged by Junio C Hamano -- gitster
-- in commit 21b839e, 13 Mar 2022)
gpg-interface/gpgsm
: fix for v2.3Helped-By: Junio C Hamano
Helped-By: Todd Zullinger
Checking if signing was successful will now accept '[GNUPG]:
SIG_CREATED
' on the beginning of the first or any subsequent line.
Not just explictly the second one anymore.Gpgsm v2.3 changed its output when listing keys from
fingerprint
tosha1/2 fpr
.
This leads to the gpgsm tests silently not being executed because of a failed prerequisite.
Switch to gpg's--with-colons
output format when evaluating test prerequisites to make parsing more robust.
This also allows us to combine the existinggrep
/cut
/tr
/echo
pipe for writing thetrustlist.txt
into a singleawk
expression.
git merge --no-ff -m msg signed_tag_x509_nokey && GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey
Solution 2:[2]
I had the same issue. I solved it by:
- First ensure that the key is not expired:
gpg --list-keys
- If it is still valid restart the gpg-agent:
gpgconf --kill gpg-agent
- It should work now.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VonC |
Solution 2 | user3265569 |