Location aware config in git

Something you should know about, because it is really useful:

It is possible to change the (global) git configuration depending on the folder you are in.

For example - when mixing work-related and private projects on the same machine:

~/.gitconfig:

1
2
3
4
5
6
[user]
    name = Some Name
    email = my.personal.address@example.org

[includeIf "gitdir:~/code/work/"]
    path = ~/code/work/.gitconfig

And then inside ~/code/work/.gitconfig:

1
2
[user]
    email = my.work.address@example.com

I rely on this daily - It is very useful!

So long!