Conditionals in Git Config

1 min read
We can use conditionals in Git config. In my case I have separate configs for Personal and Work projects and its decided based on directory.
An example `.gitconfig` file:
[user]
name = Arunvel Sriram
email = my-personal-email@gmail.com
# work specific gitconfig for all
# projects inside ~/work/ directory
[includeIf "gitdir:~/work/"]
path = .gitconfig-work
Sample `.gitconfig-work` file:
[user]
name = Arunvel Sriram
email = my-work-email@company.com
My .gitconfig
file is available here in my dotfiles repo.
1
Subscribe to my newsletter
Read articles from Arunvel Sriram directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Arunvel Sriram
Arunvel Sriram
Engineering @ Equal Experts | Ex-Thoughtworks | DevOps | Polyglot | Backend | Open Source