Search code examples
gitgnupg

Git does not ask me for gpg passphrase and fails my commit


When I do git commit -a -S -m "Commit Message", I get this error:

You need a passphrase to unlock the secret key for
user: "Username (Gpg Key) <email-id>"
2048-bit RSA key, ID 2487BE7C, created 2016-10-03

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

But, it doesn't even ask/prompts for my passphrase when I commit. So, how and where do I enter my passphrase while using gpg's -S flag?


Solution

  • I had the similar thing. I had the gpg and gpg2 binaries, both pointing to GPG version 2.0.30. I wasn't being prompted for my passphrase.

    In your bash profile (I did it in my .zshrc file) add the following line:

    export GPG_TTY=$(tty)