Imagine that you’re working for over one company. each company you have a different name, and a separate email address. Using a global git profile with your personal email address works, but GitLab won’t display your avatar correctly as your account email. So how to do that?
The include and includeIf sections allow you to include config directives from another source. So my idea is creating a separate folder for each environment (or company) and then using includeIf to let gitconfig including the correct config profile. Try it now!
personal: For personal projects
You can create files anywhere with the following content:
[user] name = JackTT email = email@example.com
[user] name = JackTT email = firstname.lastname@example.org
[user] name = JackTT email = email@example.com
~/.gitconfig file with the following content:
[includeIf "gitdir:/Volumes/Data/personal/"] path = ~/.gitconfig-personal [includeIf "gitdir:/Volumes/Data/google/"] path = ~/.gitconfig-google [includeIf "gitdir:/Volumes/Data/facebook/"] path = ~/.gitconfig-facebook