Following this SO post and the linked guidance, I set up a condition configuration like the following...
$ cat ~/.gitconfig
[user]
name = Random J. Hacker
email = [email protected]
[includeIf "gitdir:~/work/*"]
path = ~/work/.gitconfig
$ cat ~/work/.gitconfig
[user]
name = Serious Q. Programmer
email = [email protected]
In this way, all of the repositories I do clone when I'm working for Programmer Co. get my @programmer.biz work email address assigned as the default --author
credential; and every random repo I clone to my desktop or /tmp
or ~/.vscode
or wherever gets my super legit @hack.er credential assigned as the author.
Unfortunately, I noticed the following behaviour...
$ git clone [email protected]:programmerbiz/repo.git
$ cd repo/
$ git config --list | grep user
user.name=Random J. Hacker
[email protected]
user.name=Serious Q. Programmer
[email protected]
Oh no! My @hack.er user is picked up by the business repo!
I would like to automatically configure one and only one default [user]
for all repos without resorting to a bash script. Is there an includeIf.Not
operator, [else]
block syntax, or similar that I can use in ~/.gitconfig
to achieve this? The conditional includes documentation does not appear to support this use case.