Conditional Git Configs


Often you need a different a for work and personal projects. You can use a conditional include to set attributes based on the current working directory.



  name = John Doe
  email =
[includeIf "gitdir/i:~/work/"]
  path = ~/work/.gitconfig


  email =

Navigate to a Git repository inside ~/work and run:

git config -l

You will see the following if you did it correctly: Doe

Last one wins.