Skip to content

Instantly share code, notes, and snippets.

@paolocarrasco
Last active November 7, 2025 17:25
Show Gist options
  • Select an option

  • Save paolocarrasco/18ca8fe6e63490ae1be23e84a7039374 to your computer and use it in GitHub Desktop.

Select an option

Save paolocarrasco/18ca8fe6e63490ae1be23e84a7039374 to your computer and use it in GitHub Desktop.

Revisions

  1. paolocarrasco revised this gist Nov 6, 2025. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -53,12 +53,13 @@ It means that is not finding the key that was set. You would need to set up the
    ```

    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. 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).
    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!
  2. paolocarrasco revised this gist Nov 6, 2025. 1 changed file with 18 additions and 13 deletions.
    31 changes: 18 additions & 13 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,42 @@
    Problem
    -------

    You have installed GPG, then tried to commit and suddenly you see this error message after it:
    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
    ```

    Debug
    -----
    Understand the error (important to solve it later!)
    ----------------------------------------------------

    For understanding 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`):
    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:
    Probably you will see something like this
    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 <your GPG key>
    ```
    (Check if your GPG key is correct)

    (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 <your GPG key>
    ```
    👆🏻 With this now you could see what happened in detail!
    👆🏻 Executing this will give you a useful output that will allow you to see what happened in detail 🙌🏼

    Solutions
    ---------
    Check now the possible solutions based on your findings 👀

    We can have many problems, but I list what I found:
    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).
    @@ -49,8 +54,8 @@ It means that is not finding the key that was set. You would need to set up the

    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. 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).
    2. 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):
    ```
    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
  3. paolocarrasco revised this gist Nov 6, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ It means that is not finding the key that was set. You would need to set up the

    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. 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).
    2. 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 want):
    2. 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):
    ```
    brew install pinentry-mac
    echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
  4. paolocarrasco revised this gist Nov 6, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ It means that is not finding the key that was set. You would need to set up the

    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. 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).
    2. A specific and popular solution posted for mac users:
    2. 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 want):
    ```
    brew install pinentry-mac
    echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
  5. paolocarrasco revised this gist Nov 6, 2025. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -49,5 +49,11 @@ It means that is not finding the key that was set. You would need to set up the

    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. 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).
    2. A specific and popular solution posted for mac users:
    ```
    brew install pinentry-mac
    echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
    killall gpg-agent
    ```

    Hope it helps!
  6. paolocarrasco revised this gist Aug 3, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -46,6 +46,8 @@ It means that is not finding the key that was set. You would need to set up the
    ```shell
    git config --global user.signingkey <your key>
    ```

    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. 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!
  7. paolocarrasco revised this gist Sep 24, 2021. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -37,15 +37,15 @@ We can have many problems, but I list what I found:
    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):
    1. List the secret keys available in GPG.
    ```shell
    gpg --list-secret-keys --keyid-format=long
    ```
    1. Copy your key
    1. Set your key for your user in git
    ```shell
    git config --global user.signingkey <your key>
    ```
    - 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 <your key>
    ```
    1. 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!
  8. paolocarrasco revised this gist Sep 24, 2021. 1 changed file with 14 additions and 6 deletions.
    20 changes: 14 additions & 6 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ For understanding what's going on, first check what git is doing, so add `GIT_TR
    GIT_TRACE=1 git commit
    ```

    With that you can see what the problem can be. And what GPG is doing:
    With that you can see what GPG is doing:
    Probably you will see something like this
    ```
    10:37:22.346480 run-command.c:637 trace: run_command: gpg --status-fd=2 -bsau <your GPG key>
    @@ -26,18 +26,26 @@ Execute that gpg command again in the command line:
    ```
    gpg --status-fd=2 -bsau <your GPG key>
    ```

    Now you could see what happened in detail!
    👆🏻 With this now you could see what happened in detail!

    Solutions
    ---------

    We can have many problems, but I list what I found:

    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 (In my case the message said `gpg: signing failed: No secret key` as it can be see in the image below).
    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.
    It means that is not finding the key that was set. You would need to set up the GPG key in Git (again):
    1. List the secret keys available in GPG.
    ```shell
    gpg --list-secret-keys --keyid-format=long
    ```
    1. Copy your key
    1. Set your key for your user in git
    ```shell
    git config --global user.signingkey <your key>
    ```
    1. 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!
  9. paolocarrasco revised this gist Sep 24, 2021. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -22,18 +22,22 @@ Probably you will see something like this
    ```
    (Check if your GPG key is correct)

    Repeat that gpg command again in the command line:
    Execute that gpg command again in the command line:
    ```
    gpg --status-fd=2 -bsau <your GPG key>
    ```

    Now you could see what happened in detail!

    Solutions
    ---------

    We can have many problems, but I list what I found:

    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 (the message says `gpg: signing failed: No secret key`).
    It means that is not finding the key that was set (it happened to me because I preppended a number).
    1. Another thing could be that the secret key was not set (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.
    1. 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!
  10. paolocarrasco revised this gist Sep 24, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,9 @@ fatal: failed to write commit object
    Debug
    -----

    For understanding what's going on, first check what git is doing:
    For understanding 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`):
    ```
    GIT_TRACE=1 git rebase --continue
    GIT_TRACE=1 git commit
    ```

    With that you can see what the problem can be. And what GPG is doing:
  11. paolocarrasco created this gist Aug 29, 2018.
    39 changes: 39 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    Problem
    -------

    You have installed GPG, then tried to commit and suddenly you see this error message after it:
    ```
    error: gpg failed to sign the data
    fatal: failed to write commit object
    ```

    Debug
    -----

    For understanding what's going on, first check what git is doing:
    ```
    GIT_TRACE=1 git rebase --continue
    ```

    With that you can see what the problem can be. And what GPG is doing:
    Probably you will see something like this
    ```
    10:37:22.346480 run-command.c:637 trace: run_command: gpg --status-fd=2 -bsau <your GPG key>
    ```
    (Check if your GPG key is correct)

    Repeat that gpg command again in the command line:
    ```
    gpg --status-fd=2 -bsau <your GPG key>
    ```

    Solutions
    ---------

    We can have many problems, but I list what I found:

    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 (the message says `gpg: signing failed: No secret key`).
    It means that is not finding the key that was set (it happened to me because I preppended a number).

    Hope it helps!