0

I work remotely, and I have two main folders on my PC – one for personal projects and another for work projects. I obviously need to keep the identities separate for repositories residing deep down in those folders. Git doesn't natively support this use case. Is there any known good practice to address this scenario?

Note I'm not talking about remotes; I'm talking about my identity as a commit author (i.e. name and, most importantly, e-mail address).

TL;DR: Use [includeIf], it solves this.

LE: Currently reviewing and testing the recommended solution (it looks promising). Will come back with a resolution.

LE2: I just can't get [includeIf] to work for now. Will retry tomorrow and will come back with a resolution. I assume I'm doing something wrong.

LE3: I'm testing this on Windows, using GitExtensions. This doesn't work when I commit using the GitExtensions GUI. But if I execute git config --show-origin --get user.email from the GitExtensions shell, it does report the work e-mail address correctly (my default is personal, [includeIf] is work). I'm starting to think this is related to GitExtensions somehow, even though it's just supposed to be a thin GUI layer above git. Kinda confusing.

LE4: GitExtensions is buggy in that it displays the wrong committer in the commit dialog, but the actual git commit properly honors the [includeIf] directive. Thank you!

Bogdan Stăncescu
  • 5,320
  • 3
  • 24
  • 25
  • 1
    https://stackoverflow.com/a/43654115/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+multiple+email – phd Feb 25 '23 at 22:01
  • 1
    For me the best solution is to keep work and personal repos in 2 different parent directories and use conditional include to have a specific identity in all the repos of one of the parent folder like done in https://stackoverflow.com/a/43654115/717372 – Philippe Feb 25 '23 at 22:11

0 Answers0