There is a little bit more background here: I’m using Windows Subsystem Linux(WSL) now, which means I was running Emacs in a virtual machine with Debian Linux distro.

And also I ran Emacs in GUI mode with WSL, the pinentry for GnuPG Agent is: /usr/bin/pinentry-gtk2, everything was prefect.

This morning I couldn’t commit with Magit in Emacs, when I was running my Emacs in Terminal Text Mode.

The first thing I had done is change the pinentry:

sudo apt install pinentry-tty
sudo update-alternatives --config pinentry
# Choice /usr/bin/pinentry-tty


That not work, even in the bash without Magit, then I tried:

export GPG_TTY=\$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null


Then I could commit in bash, but still couldn’t commit with Magit.

Finally I realized that I executed above commands that still in the Emacs, with vterm. So:

1. I quit the Emacs.
2. Executed the above commands.
3. Start Emacs again.

And it works, for temporary, as GnuPG Agent has cached the credential, we just didn’t need to enter password.