I like to mess with my dotfiles and every so often, I find out about a new way to do things and I spend more time than I should learning how to use it.
A few years ago I learned about includeIf for including specific files if some condition was met for git. The example that I first saw was doing:
So that ~/.config/git/personal is only included for git directories under ~/code and ~/.config/git/work is only included for directories under ~/work. The contents of those included files varies but usually it contains your git identity, signing keys, etc. Here's an example of what that could look like:
That works pretty well but I usually organize all my code in ~/workspace regardless of whether its personal, work-1, work-2, etc. I wanted to be able to configure git depending on where that repo actually lives instead of where the directory is in my machine. Then I found out about hasconfig:remote.*.url:!
This makes it so that I can configure git conditionally if the given remote URL exists for that directory I'm currently working in.