Most of my Git repo can be classified as github repo or company repo, both have a considerable number. And obviously I need to use different email address for this two different kind of repos.
I read the git manual and searched a lot, and find there are only two ways to config the user email: globally and per-repo.
So, If I want to use different email address for this two kind of repos, I have two choice:
- Set the global email address to one of them, and carefully set per-repo email address for other repos.
- Always set email address per-repo, and force it via
git config --global user.useConfigOnly true
Neither is satisfactory :(
The ideal solution maybe looks like url.insteadOf
[url "https://github"]
insteadOf = git://github
user_email = xxx@gmail.com
So is there any solution for this case? maybe via git hook or some other magic?
Notice: my question is very different from this one since I need Automatic Switching not just add per-repo configs one by one.