I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do git commit
I looked at so many other stackoverflow
In my case, I had to match the name stored in GitHub settings to the name and comment of the key.
So if gpg --list-keys returns uid [ultimate] Joe Blogs (fancy comment) your name in .gitconfig should be Joe Blogs (fancy comment).
Initially, I had my name set as Joe Blogs and GPG would not find my key and show the "no secret key" error in strace. Unfortunately, that error didn't appear without strace and one would get the generic
error: gpg failed to sign the data
fatal: failed to write commit object