📅 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:
~/.gitconfig
file, I introduce a conditional include using includeIf
for repos that lie inside my ~/funrepos
directory:[user]
name = Joe Guy
email = joe.guy@foobar.com
[includeIf "gitdir:~/funrepos/"]
path = ~/.gitconfig.funrepos
~/.gitconfig.funrepos
with a different email to use for fun hack repos:[user]
email = fun.repos@foobar.com
Tried with: Git 2.17.1 and Ubuntu 18.04