If you use Git for private projects and for university or work, you probably know this problem: every server expects a different email address. I push my private projects to GitHub with my private address, but my university, ZHAW, runs a GitHub Enterprise Server at github.zhaw.ch that only accepts my student email.
Setting user.email in every single repository works, until you forget it once. In this guide, we'll configure Git so it picks the right email automatically, based on the remote URL of the repository.
The feature we’re going to use, conditional includes with hasconfig:remote.*.url, was added in Git 2.36. So first check your version:
Update or initially install it with:
Make your private email the global default. Git uses it for every repository that doesn’t match a special rule:
Next, create a second config file that only contains the settings for your enterprise server. This command creates ~/.gitconfig-enterprise (the name doesn’t matter) and writes your work email into it:
…

































