You can disable this by running git config commit. gpgsign false This sets the configuration locally instead of globally.
For troubleshooting, two things to first try:
git config --global gpg.program gpg2
, to make sure git uses gpg2
and not gpg
echo "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, you re-try git commit
and still get a "failed to sign the data
" error, do:
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, 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, 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, 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
Git needs to know which key it is signing with.
After you have setup GPG, gpg-agent, and your gpg.conf files (see this guide), you need to run
git config --global user.signingKey EB11C755
Obviously, replace the public key at the end with your own. If you want every commit to be signed by default, use
git config --global commit.gpgsign true
$ gpg2 -K --keyid-format SHORT # <-- Shows your keys, e.g.:
/home/<username>/.gnupg/pubring.kbx
-------------------------------
sec rsa4096/0754B01E 2019-02-02 [SCA] <--secret key
C396BF3771782D7691B0641145E11B080754B01E
uid [ultimate] John Doe <[email protected]>
ssb rsa4096/A20AB8EC 2019-02-02 [E] <--public key
sec rsa4096/25C504D5 2019-02-02 [SCA] [revoked: 2020-06-01]
08BFF49B9E07E4B4B0C4946B645B6C1425C504D5
uid [ revoked] John Doe <[email protected]>
uid [ revoked] [jpeg image of size 2670]
Where A20AB8EC
is the key ID you're looking for from this example.
Somehow your git is configured to GPG sign every commit. Signing with GPG isn't required to commit or push using git. It's likely giving the error because your gpg signing mechanism isn't configured yet.
If you're new to git, try to get it working first without GPG signing at first, then add signing in later if you really need it.
You can verify how your git is configured with regards to gpg by doing:
git config -l | grep gpg
Which may produce zero or more lines, including:
commit.gpgsign=true
If "commit.gpgsign" is true, then you have gpg signing enabled. Disable it with:
git config --global --unset commit.gpgsign
Then try to run your commit again. It should now run without gpg signing. After you get the basic git working, then you should try adding gpg signing back to the mix.
I am using it. It has support for zsh and works on Windows Subsystem for Linux:
export GPG_TTY=$(tty)
Other users have confirmed that above is the only change required for MacOS (e.g. Catalina 10.15.7). For Macs add above to ~/.zshrc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With