Sometimes I use my terminal for personal work, like this article. In those cases, I like my git commits to use my personal email address and not my work email.
Luckily, all the repos that I use for work have the company name in their path, so I set up a dynamic include in my
.gitconfigthat overrides my configured email address for those directories. It looks like this:
[user] name = Adam Hollett email = firstname.lastname@example.org [includeIf "gitdir/i:**/workcompany/**"] email = email@example.com
The includeIf directive in
.gitconfigonly activates the configuration in that category if its pattern is matched. In this case, it looks for the name workcompany in the current path and sets a work email address if it finds it.
Via Adam Hollett.