Problem ------- You have installed GPG, then tried to perform a `git commit` and suddenly you see this error message after it 😰 ``` error: gpg failed to sign the data fatal: failed to write commit object ``` Understand the error (important to solve it later!) ---------------------------------------------------- To understand what's going on, first check what git is doing, so add `GIT_TRACE=1` at the beginning of the command you used before (`git commit` or `git rebase` or `git merge` or anything like that): ``` GIT_TRACE=1 git commit ``` With that you can see what GPG is doing. You will see something like this: ``` 10:37:22.346480 run-command.c:637 trace: run_command: gpg --status-fd=2 -bsau ``` (First thing would be to check if your GPG key is correct) Execute that gpg command again in the command line: ``` gpg --status-fd=2 -bsau ``` 👆🏻 Executing this will give you a useful output that will allow you to see what happened in detail 🙌🏼 Check now the possible solutions based on your findings 👀 Some solutions -------------- We can have many problems, but I list what I found and some solutions posted in the thread: 1. It could be that the *GPG key was expired*: https://stackoverflow.com/a/47561300/532912 1. Another thing could be that *the secret key was not set properly* (In my case the message said `gpg: signing failed: No secret key` as it can be see in the image below). ![image](https://user-images.githubusercontent.com/1524522/134691912-b0fdd04b-344a-4b02-9ff9-68cba7f9f0fb.png) It means that is not finding the key that was set. You would need to set up the GPG key in Git (again): - List the secret keys available in GPG. ```shell gpg --list-secret-keys --keyid-format=long ``` - Copy your key - Set your key for your user in git ```shell git config --global user.signingkey ``` 1. Another popular solution that could help was shared here by [@NirajanMahara](https://github.com/NirajanMahara): https://gist.github.com/paolocarrasco/18ca8fe6e63490ae1be23e84a7039374?permalink_comment_id=3767413#gistcomment-3767413 1. A specific and [popular solution](https://gist.github.com/paolocarrasco/18ca8fe6e63490ae1be23e84a7039374?permalink_comment_id=4726796#gistcomment-4726796) posted for mac users by @lehaiquantb suggests to install `pinentry` (I'm not a fan of installing stuff but if you are ok with it): ```shell brew install pinentry-mac echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf killall gpg-agent ``` 5. You can see in the thread of this gist other ways to find the solution to other problems. I recommend to read the [Github guide for signing commits with GPG](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key). Hope it helps!