Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to make Git pick config conditionally

📅 2020-Sep-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ conditional include, git ⬩ 📚 Archive

Git has a feature called Conditional Include using which I can make it use a different config file depending on the condition such as the repo directory name or branch name.

For example, depending on the repo directory name I could make Git automatically use a different email config for checking in commits. Here is how to do that:

    name = Joe Guy
    email =

[includeIf "gitdir:~/funrepos/"]
    path = ~/.gitconfig.funrepos
    email =

Tried with: Git 2.17.1 and Ubuntu 18.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧