Skip to content

How to fix ‘GPG failed to sign the data’ error?

  • by
  • 2 min read

When building a program, it’s common practice for developers to create multiple versions of their program as they progress along, adding more features or resolving bugs. 

Git is a great way to manage versions and code as well as work collaboratively on a single project. However, while it might seem like an easy-to-manage system on the outside, there are a lot of small things that can go wrong and cause uncalled-for errors.

In this article, we’re talking about the “GPG failed to sign the data” error on Github and three solutions you can try to fix the problem. 

Also read: Python vs R: Which one is better?

Check GPG version

If you aren’t already on the latest GPG version, there’s a chance that you might be deprecated by an update. You can do this by entering the following commands in a terminal one at a time. 

brew upgrade gnupg
brew link --overwrite gnupg
brew install pinentry-mac

If you’re on Apple’s M1 silicon, try this command instead. 

echo "pinentry-program /opt/homebrew/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf 
killall gpg-agent

For older homebrew installations, try this command.

echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent

The aforementioned commands are divided into two parts. One installs GPG 2 and the latter is a hack required to use the package which kills the GPG service and restarts it again before you can sign commits.

Check the GPG environment variable

If you’re using gnupg2 and gpg-agent version 2 or above, check to see if you’ve set the GPG_TTY environment variable correctly. If not, you can do this by entering the following command.

export GPG_TTY=$(tty)

If you’re using fish, try this command instead.

set -x GPG_TTY (TTY)

Restart the GPG agent

If nothing else works, you can also try restarting the GPG agent to clear out old, cached data and start afresh. Use this command to kill GPG.

killall gpg-agent

Once executed, use this command to restart the service.

gpg-agent --daemon

Also read: Is Python case sensitive when dealing with identifiers?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: