Sometimes, after you have installed GPG for Git and are trying to commit changes, you'll run into the below message:

```
error: gpg failed to sign the data
fatal: failed to write commit object
```

## How to debug the issue

First, you should start with a simple 'GIT_TRACE=1' command in order to understand what is happening.

```
GIT_TRACE=1 git commit
```

Execute the gpg in the command line again, which should look similar to this:

```
gpg --status-fd=2 -bsau <your GPG key>
```

This command will provide you ample context into what happened.

## How to implement the solution

Sometimes, the problem is that your GPG key has expired, the solution for which is to run the failing command manually, as such:

```
$ echo "dummy" | gpg -bsau <your GPG key>
gpg: skipped "<your GPG key>": Unusable secret key
gpg: signing failed: Unusable secret key
```

Othertimes, you might not have properly set the secret key. So, to solve it:

1. List the secret keys available in GPG

```
gpg --list-secret-keys --keyid-format=long
```

2. Copy and set your key for the user in Git

```
git config --global user.signingkey <your GPG key>
```

## How to solve the issue on MacOS

Here a few steps in order to try and get the issue fixed:

1. Run `brew uninstall gpg`
2. Run `brew install gpg2`
3. Run `brew install pinentry-mac`

Step 3 applies only if you're lacking Pinentry on your MacOS installation.

4. Use `gpg --full-generate-key` to generate a new key for GPG.

5. Use `gpg --list-keys` to access the key generated previously.

6. Use `git config --global user.signingkey <your GPG key>` to set your key from the above list

7. Run `git config --global gpg.program /usr/local/bin/gpg`

8. Run `git config --global commit.gpgsign true`

As a last step, if you want to export your key to GitHub, run `gpg --armor --export <key>`. You can find your GPG keys at this link: [https://github.com/settings/keys](https://github.com/settings/keys?ref=strawberryjam.ghost.io).

## How Jam can help you debug faster

Debugging issues like the "GPG failed to sign data" error can be time-consuming, especially when dealing with cryptographic keys and configuration settings. The good news is you can save yourself a lot of time debugging tickets by asking your team to try logging issues with [Jam’s free bug reporting browser extension](/content/?ref=strawberryjam.ghost.io). Jam makes it easy for anyone to create developer-ready bug reports by auto-including [console logs, network requests](/content/tracing?ref=strawberryjam.ghost.io), and [steps to reproduce the issue](/content/blog/launching-today-debug-timeline-you-never-have-to-write-repro-steps-again/?ref=strawberryjam.ghost.io) along with the screen recording.

With Jam, you can capture detailed debug data just by recording your screen. Jam packages it all up into a link you can share, or a [ticket in your issue tracker](/content/docs/integrations/?ref=strawberryjam.ghost.io). Now everyone can log comprehensive bug reports and developers can fix bugs faster without having to follow up.

## Dealing with bugs is 💩, but not with Jam.

Capture bugs fast, in a format that thousands of developers love.

[Get Jam for free](/content/?utm_source=jam-blog&utm_medium=blog&utm_campaign=jam_blog_footer_2023_01/index.html)
