Home > Blockchain >  Git for Win includeIf personal/work account
Git for Win includeIf personal/work account

Time:03-23

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 = [email protected]
[includeIf "gitdir/i:D/Projects/Work/"]
    path = .gitconfig-work

~/.gitconfig-work

[user]
    name = Work
    email = [email protected]

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  [email protected]

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

Anything that I'm missing? Thanks!

CodePudding user response:

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