Skip to content

Instantly share code, notes, and snippets.

@Peredery
Last active May 19, 2024 08:36
Show Gist options
  • Save Peredery/38d0538dd34381bbd9d13414269a1f27 to your computer and use it in GitHub Desktop.
Save Peredery/38d0538dd34381bbd9d13414269a1f27 to your computer and use it in GitHub Desktop.
FIX - gpg failed to sign the data fatal: failed to write commit object

FIX - gpg failed to sign the data fatal: failed to write commit object

!!! For M1/M2 apple silicon see this comment:

https://gist.github.com/Peredery/38d0538dd34381bbd9d13414269a1f27?permalink_comment_id=4559612#gistcomment-4559612

For MacOS | Mojave | High Sierra

Step 1 - Upgrade current gpg

brew upgrade gnupg

Step 2 - Install pinentry-mac

brew install pinentry-mac 

Step 3 - Update gpg-agent.conf

echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf 

Step 4 - Restart gpg-agent

killall gpg-agent && gpg-agent --daemon

Step 5 - Configure git to use GPG

git config --global gpg.program gpg
git config --global commit.gpgsign true
@vsaladhagu
Copy link

thank you so much, worked for me !!

@menzen
Copy link

menzen commented Jun 8, 2023

super nice, works for me too !! THX

@mamiu
Copy link

mamiu commented Jul 24, 2023

GPG Git integration on macOS Ventura (and newer versions):

Here are all steps combined to setup and integrate GPG and Git on the latest macOS:

brew reinstall gnupg
brew upgrade gnupg
brew link --overwrite gnupg
brew install pinentry-mac
echo "pinentry-program $(brew --prefix)/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
git config --global gpg.program (brew --prefix)/bin/gpg
git config --global commit.gpgsign true
sudo chown -R $USER ~/.gnupg/
chmod 700 ~/.gnupg/
killall gpg-agent && gpg-agent --daemon

Thanks to @Peredery and @shaunsim15!

@kushal-chhetri7
Copy link

Thanks worked For me 👍

@foxmean
Copy link

foxmean commented May 16, 2024

Thanks! I use MacBookAir M1 Machine and the modified version of this guide from @shaunsim15 works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment