I have messed up .gnupg/pubring.kbx file. I don't have any backup of the .gnupg folder. But still, I have my GPG Public and Private keys. I am unable to unlock git-crypt. When I list the .gnupg folder in my mac, lt lists these files:
S.gpg-agent S.gpg-agent.extra openpgp-revocs.d pubring.kbx
trustdb.gpg S.gpg-agent.browser S.gpg-agent.ssh
private-keys-v1.d pubring.kbx~
Is there any way to recover back that file so that I can do git-crypt unlock? OR Is there any way to do git-crypt unlock without that file?
Since, you have your public and private key in hand. Here are the steps you will need to follow:
Goto your gnugp dir
cd ~/.gnupg
Deleting the corrupted pubring.kbx
rm pubring.kbx
Copy pubring.kbx~ as pubring.kbx. This will give you an empty pubring which will not have any secret keys. Its like a fresh start.
cp pubring.kbx~ pubring.kbx
Import your public key
gpg --import <your-public-key-file.asc>
Good luck!