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
I had this error on macos - to try and troubleshoot I tried listing keys to see if they had expired using gpg2 --list-keys
- I verified that the keys had not expired and that the proper key were set in my config using git config --global user.signingkey
.
After I had run those commands I was suddenly able to do signed commits again without problems. I did not change my config files or keys - I did not even create a fresh Terminal instance. It just seemed like the gpg2 was somehow in a weird state on my mac.
Check for your key to be expired. Once you fix the expiration date (no need to create a new key unless you want to), git
will work as normal.
One way to fix the expired key:
(Note: $
represents command line prompt, type the commands after the prompt; press Enter after each command)
$ gpg2 --list-keys
to find the appropriate key id (characters after \
on pub
line)
$ gpg2 --edit-key <key id>
- this opens the gpg shell, with prompt changed to gpg>
gpg> expire
- follow instructions to set new expiration date for primary key
Next, if there are subkeys that are expired (sub
shows on the line), reset their expiration dates, too:
gpg> key 1
- selects first subkey
gpg> expire
- follow instructions to set new expiration date for subkey
Repeat for each subsequent subkey, as needed.