Commit list showing a verified signature

error: gpg failed to sign the data

A couple of months ago I noticed that commits I’ve done through the GitHub web interface were receiving a “Verified” badge while commits done through the Git command line in WSL (Windows Subsystem for Linux) at my local dev machine weren’t.

I’m all for badges so I followed the steps found at About commit signature verification to setup GPG signing. The thing is, there was something still missing and as a result, when trying to commit I was getting an error message as follows:

error: gpg failed to sign the data
fatal: failed to write commit object

Fortunately, the solution is simple. Export a variable named GPG_TTY as follows:

export GPG_TTY=$(tty)

I ended appending it to ~/.bashrc so as to persist it between terminal sessions.

Published by

Alfred Myers

I have been interested in computers since I got my hands on a magazine about digital electronics back in 1983 and programming them has been paying the bills since 1991. Having focused on Microsoft-centric technology stacks for the best part of two decades, in recent years I’ve been educating myself on open source technologies such as Linux, networking and the open web platform.

2 thoughts on “error: gpg failed to sign the data”

  1. For the benefit of your readers please consider revising this post to explain why this worked for you.

    1. I’m not sure why this setting has to be done manually, but it is stated in the documentation for gpg-agent ( and it has been this way for a long, long time (
      There’s an opened issue over at GnuPG ( describing the issue on Debian, but I was able to reproduce the error on Ubuntu 18 and 19, and CentOS 8.0 as well.

Comments are closed.