Can't sign GPG Commit

I can’t sign my GPG commits no matter what. I have tried every method possible, same output again and again.

git commit -m "..."
error: gpg failed to sign the data
fatal: failed to write commit object

Most of the search yielded this command export GPG_TTY=$(tty) which doesn’t work for me.
However, echo "test" | gpg --clearsign works. There is no valuable debug information that I can work it. Kindly help!

What’s the output of

git config --list


What shell are you working in?

I had this issue when I was using fish, but good old bash worked just fine.

1 Like
credential.helper=cache[My Mail][My User Name]
user.signningkey=[My Key]
remote.origin.url=git@[Git Repo].git

Zsh and Oh-My-Zsh, with gpg-agent plugin on. Tried with bash not working.

Hm. Pretty sure that export command should have done it with bash…

I tried that too. Same error. Did you enable any systemd process?

can you open bash and execute:

git config --global gpg.program gpg2

and try again? (also in bash)


I’m not on `zsh so cannot test for you but if the above works try it there as well.


Tried in both. Same result. Is there any way to debug? Like specific error?

That’s my 0,02€… No further ideas, sorry!


1 Like

Thank you nonetheless!

I have solved it myself. Completely Removed folder:


After that generated a new GPG key and that somehow solved the problem.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.