Go to your work folder, mine is located at:
F:/Work/EnterpriseName/
And then create a .gitconfig-work
with the following data:
[user]
name = Name at work
email = [email protected]
The folder should be like this:
π EnterpriseName
βββ π project01
βββ π project02
βββ π project03
βββ π .gitconfig-work
Navigate to your current .gitconfig
and open it.
Usually it's at C:\Users\your-user
It should have something like:
[user]
name = Icaruk
email = [email protected]
That's the global config, that will be used as the default one. If it doesn't exist, create it with these commands:
git config --global user.name "Icaruk"
git config --global user.email "[email protected]"
Add the following lines:
[includeIf "gitdir:F:/Work/EnterpriseName/"]
path = F:/Work/EnterpriseName/.gitconfig-work
- The first path is your work path, it must end with "/".
- The second path is your
.gitconfig-work
that you created on your work folder. But it can be anywhere, just point at it.
Go to your work folder and open any project, then run:
git config user.email
It should display your work email.
Now go to any project that isn't located inside your work folder and run the same command. It should display your default email.