Git for Win + includeIf personal/work account

Viewed 94

I'd like to setup my git config with different personal/work accounts but the work account is never loaded.

Win10, Git for Windows v2.35.1(2), Git bash shell

~/.gitconfig

[user]
    name = Personal
    email = personal@personal.com
[includeIf "gitdir/i:D/Projects/Work/"]
    path = .gitconfig-work

~/.gitconfig-work

[user]
    name = Work
    email = work@work.com

If I git init a new repo inside the work folder, e.g. D:\Projects\Work\repo and issue

git config --show-origin --get user.email

it shows:

file:C:/Users/<my-user>/.gitconfig  personal@personal.com

I have the latest git, use the case insensitive gitdir switch and the end "/" in the path.

Anything that I'm missing? Thanks!

1 Answers

As far as I can tell, you're only missing a colon (:) in the gitdir path, so it should be:

[includeIf "gitdir/i:D:/Projects/Work/"]

instead of:

[includeIf "gitdir/i:D/Projects/Work/"]
Related