less than 1 minute read

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 .gitconfig that overrides my configured email address for those directories. It looks like this:

[user]
  name = Adam Hollett
  email = adamh@example.com

[includeIf "gitdir/i:**/work.company/**"]
  email = adamh@work.company.com

The includeIf directive in .gitconfig only activates the configuration in that category if its pattern is matched. In this case, it looks for the name work.company in the current path and sets a work email address if it finds it.

Via Adam Hollett.

Tags: ,

Categories:

Updated:

Leave a comment