I installed Git on my Mac and then tried to set up GPG signature verification by following the steps outlined in Github.
The first time I did a test git commit
through the Mac OS Terminal I was requested my passphrase and the commit was properly signed and pushed through. No problems.
Then I tested the signature verification through the Atom editor. This time, however, the git commit
signing failed.
I tried looking for solutions on Stack Overflow and GitHub but was unable to find any that worked although I did try some of the suggestions proposed.
Unfortunately, now when trying to git commit
via the Terminal, I get the following error message:
error: cannot run --version: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
I have spent a few days trying to find a solution online but have not been successful.
I do not understand the first line of the error message ( cannot run --version: no such file or directory ) and have not been able to find a similar issue online.
Over the last couple of days I have tried a lot of things based on suggestions from the following sites:
I have also done the following:
Error: Commit failed - exit code 128 received, with output:
'error: gpg failed to sign the data fatal: failed to write commit object'
Unable to commit. Error: gpg failed to sign the data fatal: failed to write commit object
Unfortunately the problem persists and I no longer know what to try.
The output that I got for git config -l | grep -E 'gpg|sign
is:
user.signingkey=00C23E4C0619F0BD
commit.gpgsign=true
gpg.program=/usr/local/MacGPG2/bin/gpg2
I could do the following:
git config --global commit.gpgsign false
But this would not resolve the issue and I would still not be able to sign my git commit
.
What confuses and frustrates me is that it worked during my first git commit
after setting everything up following the steps outlined in Github's official guidelines. I am not sure what I did since then so that it no longer works. I have tried to back track and erase any changes but so far I have still not been able to resolve this issue.
Any help and guidance would be greatly appreciated. Thank you!
Out of curiosity I tried doing a git commit
through Terminal with a different local repo. The commit went through without a glitch and when I checked on Github it was signed and verified. I did further tests to commit and sign via GitHub Desktop and Atom, everything works fine without any issues. This is good news and gives me hope. However, I still have no idea why git commit
works on one repo and not on the other repo I was testing with. The original repo I was testing with still cannot git commit
and gives the same error message that I detailed above... I wonder what is wrong?
I am running the following:
After testing, since the issue seems to be only on one of my local git repos and not on any other local git repos, I concluded that overall, Git, GitHub Desktop, Atom, and GPG Signing are all working fine and the issue is specific to that one local git repo.
Although I have tried my best and still not found out exactly what is wrong with the buggy git repo and because I don't seem to be getting any additional leads/solutions from Stack Overflow I decided to do the following:
git clone
redo tests with git commit
and GPG signing via the Terminal, GitHub Desktop, and Atom.I guess I might never know what really happened but I am glad to confirm that at least everything is working again normally. Thank you @bk2204