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

:question:

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
user.email=[My Mail]
user.name=[My User Name]
user.signningkey=[My Key]
commit.gpgsign=true
gpg.program=gpg
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@[Git Repo].git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main

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)

:question:

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

:crossed_fingers:

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

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

:cry:

1 Like

Thank you nonetheless!

I have solved it myself. Completely Removed folder:

~/.gnupg

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.