5

I've recently upgraded to git version 2.33.1.windows.1
and includeif does not seem to be working.
Can anyone else confirm? I can't remember what my previous git version was.

My config is as follows:

.gitconfig

[user]
  name = crowne
  email = [email protected]
[includeIf "gitdir:E:/work/**"]
  path = ~/.gitconfig_work

.gitconfig_work

[user]
    name = name.surname
    email = [email protected]

The reason I upgraded was that the includeif was not taking effect recursively
on directories nested more than one directory below E:/work/

Since the upgrade it doesn't seem to be taking effect at all.

>git config -l --show-origin

Only shows entries from:

  • C:/Program Files/Git/etc/gitconfig
  • C:/Users/crowne/.gitconfig

I don't see any entries from:

  • C:/Users/crowne/.gitconfig_work
3
  • 1
    Try [includeIf "gitdir/i:E:/work"] (case-insensitive, no **).
    – phd
    Nov 16, 2021 at 12:59
  • I tried, but its still not working
    – crowne
    Nov 17, 2021 at 12:53
  • This is no longer a problem for me, I'm currently on git version 2.34.1.windows.1 however I'm also on a new computer and my work include path is now [includeIf "gitdir/i:**/work/**"] path = ~/.gitconfig_work
    – crowne
    Feb 22, 2022 at 7:49

2 Answers 2

7

I have tried git v2.35.1 and the magic was for me, to drop the ** in the end and keep the trailing slash / alone. I added also the /i option to ignore be case-insensitive.

.gitconfig, which worked for me

[user]
  name = crowne
  email = [email protected]
[includeIf "gitdir/i:E:/work/"]
  path = ~/.gitconfig_work

not working a)

[user]
  name = crowne
  email = [email protected]
[includeIf "gitdir/i:E:/work/**"]
  path = ~/.gitconfig_work

not working b)

[user]
  name = crowne
  email = [email protected]
[includeIf "gitdir/i:E:/work"]
  path = ~/.gitconfig_work
3
  • 2
    similar issue under ubuntu, after switched from Bionic (git v2.17) to Focal (git v2.25.1), I had [includeIf "gitdir:~/workspace/*"] and it worked under old version. Now I remove * : [includeIf "gitdir:~/workspace/"] equivalent to /home/myusername/workspace/** and it works fine, stackoverflow.com/a/54125961/6614155
    – bcag2
    May 27, 2022 at 12:21
  • The flat /i is important, because of the drive letter C: or c:... who knows what git thinks is the truth...
    – jeromerg
    Mar 14 at 14:32
  • if you test with git config --get user.email make sure you are actually in a git repo inside the folder, otherwise it will return the default value Jun 15 at 17:47
0

I managed to get it working for me on windows by using the following:

.gitconfig

[includeIf "gitdir:**"]
path = C:/Users/myusername/.gitconfig-personal
[includeIf "gitdir:C:/Users/myusername/Desktop/work/**"]
path = C:/Users/myusername/.gitconfig-work

.gitconfig-personal and .gitconfig-work

[user]
name = My Name
email = [email protected]

So in this case it will always default to my normal email in .gitconfig-personal and in case I go to any of the repositories in the work folder it will use the .gitconfig-work details. (I haven't tried using the case incentivise option)

1
  • isn't [includeIf "gitdir:**"] effectively [include]?
    – go2null
    Jun 13 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.