Git conditional user.email

I do have my global .gitconfig where I prefer to have my personal email address, and for every work related repository I used to do git config user.email [email protected] but there are always situations when I forget to do this. Here comes the solution: includeIf that is available since git 2.13 and makes it a bit easier. In my ~/.gitconfig I do have: [includeIf "gitdir:~/D/canonical"] path = ~/D/canonical/.gitconfig And under ~/D/canonical I simply have another .gitconfig where I set my user.email to my corporate email address. And voila, it will automagically apply a proper email for every git repository under configured path. ...

21 Mar 2025 · 1 min · 109 words · Anton Troyanov