I have found a strange error. It is OK when I commit using gpg with git under bash or zsh.

git commit -S -m "xxx"

However when I commit it under tmux, I got:

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

1 Answer 1


You need to ensure that your GPG_TTY variable is correct; add

export GPG_TTY

to your shell startup scripts, including for non-login shells (your login shells are probably OK, but not non-login shells, which is why this fails in tmux).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.