I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do git commit
I looked at so many other stackoverflow
For troubleshooting, two things to first try:
git config --global gpg.program gpg2, to make sure git uses gpg2 and not gpgecho "test" | gpg2 --clearsign, to make sure gpg2 itself is workingIf that all looks all right, one next thing to try:
brew install pinentry to ensure you have a good tool installed for passphrase entryIf after that install and you re-try git commit and still get the "failed to sign the data" error:
gpgconf --kill gpg-agent to kill any running agent that might be hungIf that says gpgconf isn’t installed or doesn’t have a --kill option, you might try this:
cp ~/.gnupg ~/.gnupg-GOOD to save a copy of your ~/.gnupg to revert to later if neededbrew install gnupg21 to install GnuPG 2.1The reason for saving a copy of your ~/.gnupg dir is that GnuPG 2.1 potentially creates/changes some key data in way that isn’t backward-compatible with GnuPG 2.0 and earlier, so if you want to go back later, you can do mv ~/.gnupg ~/.gnupg21 && mv ~/.gnupg-GOOD ~/.gnupg.
Otherwise there are some basic steps to run to check you’ve got a working GnuPG environment:
gpg2 -K --keyid-format SHORT, to check that you have at least one key pairIf the output of that shows you have no secret key for GnuPG to use, then you need to create one:
gpg2 --gen-key, to have GnuPG walk you through the steps for creating a key pairIf you get an error message saying “Inappropriate ioctl for device”, do this:
export GPG_TTY=$(tty) and/or add that to your ~/.bashrc or ˜/.bash_profile