Sometimes, from my personal machine, I need to check something work-related ; then on my personal machine, I checkout in `~/dev/myorganization/`.
Inversely, it happens sometimes that at work I need something I wrote for myself ; then on my work machine, I checkout in `~/dev/myusername/`.
This allows me to use `gitdir:` rules that handle anything `~/dev`, and I have fallbacks for everything else (who never checkouts in `tmp`?).
#
# Superman vs Clark Kent
#
# Debug Includes with: git config --list --show-origin
# the default identity, for checkouts outside of `~/dev`
[include]
path = ~/.config/git/gitconfig-default
# on my work machine, this defines Clark Kent ; on my personal machine, this defines Superman (or is it the reverse?)
# this one is not commited in my dotfiles
[include]
path = ~/.config/git/gitconfig-local
# work-related repos on personal machine
[includeIf "gitdir:/home/myusername/dev/myorganization/"]
path = ~/.config/git/gitconfig-myorganization
[includeIf "gitdir:/home/myusername/dev/gitlab.com/myorganization/"]
path = ~/.config/git/gitconfig-myorganization
# personal repos on my work machine
[includeIf "gitdir:/home/myusername/dev/myusername/"]
path = ~/.config/git/gitconfig-myusername
[includeIf "gitdir:/home/myusername/dev/gitlab.com/myusername-namespace/"]
path = ~/.config/git/gitconfig-myusername
This works nicely since years^W `includeIf` was a thing.
However, there are situations at work where I'm on a server where I didn't created `~/.config/git/gitconfig-local` (which is a manual step I always forget) and any commit from `/usr/local/src/something/` will end up configured with Superman identity.
I found out about `hasconfig:` some time ago, and took note of it for when the option would hit `git` from Debian Stable ; your comment comes the day after I accidentaly commited as Superman on some work repo checked outside of `~/dev/`. Time to add more rules!
This allows me to use `gitdir:` rules that handle anything `~/dev`, and I have fallbacks for everything else (who never checkouts in `tmp`?).
This works nicely since years^W `includeIf` was a thing.However, there are situations at work where I'm on a server where I didn't created `~/.config/git/gitconfig-local` (which is a manual step I always forget) and any commit from `/usr/local/src/something/` will end up configured with Superman identity.
I found out about `hasconfig:` some time ago, and took note of it for when the option would hit `git` from Debian Stable ; your comment comes the day after I accidentaly commited as Superman on some work repo checked outside of `~/dev/`. Time to add more rules!