Git Configs, VS Code, GPG

Happy New Year and all that! 😊 No post since December of last year, who’d have thought!

Quick one here to myself. I’ve started getting into the habit of signing all my Git commits. I was doing this for a while but not everywhere – for example, not in VS Code as it would throw the following error always:

I was too lazy to troubleshoot it until some weeks ago when I decided to look more into this and realized that simply telling Git the path to gpg on my system would do the trick. (This is a good post btw if you want to get started with signed commits and VS Code). So I opened ~/.gitconfig and added the following line to it:

Then VS Code started working fine. Great! So I guess all it needed was a nudge to where GPG was installed.

Fast forward a few weeks and today I am on my Intel iMac for the first time in weeks, and VS Code complains that it cannot sign stuff because the path is wrong. Grr!

So what I really need is a system config file where I can put the separate paths on each system. And per user config files (which I already know of). Turns out this is /usr/local/etc/gitconfig in case of Intel Macs and /opt/homebrew/etc/gitconfig in case of M1 Macs. (Thanks to this manpage and (obviously!) StackOverflow post that pointed me to a command that led me to the file).

So I moved the section above to the system config file of each system. Removed it from my user git config. Tried signing again with VS Code but it gave the same error; upon a whim I restarted VS Code (figured this was a system setting so maybe it only reads upon start) and that did the trick! Now I can sign from VS Code on both machines with no issues. Yay.