You have once again committed with your private mail address in a repo where you should actually use your company profile?
Does this sound familiar to you?
I know this only too well, sometimes noticed early enough but mostly my private profile ends up in the commit!
So if we can’t manage to remember to use the right config by ourselves, then this must happen automatically.
We have to change our gitconfig
[user] email = email@example.com # on Windows [includeIf "gitdir/i:p:/cy/**"] path = ./.gitconfig.corp
includeIf can be set to any directory in your file system, in my case my company repost are all within the same root folder.
All repositories outside this folder will use my private git profile.
Let’s create a secondary git config
[user] email = firstname.lastname@example.org
That’s all you need, you can test which profile is used in the current path with …
git config --show-origin --get user.email
The official documentation can be found here