Using different Git emails
Usually at work and at home we use different Git name/email pairs, or even per project. Pushing with correct email guarantees that your commits will be authored with a correct user identity.
This configuration stored in
.gitconfig file and looks like:
[user] name = Alex Pliutau email = email@example.com
Git 2.13 introduces conditional configuration includes. For now, the only supported condition is matching the filesystem path of the repository, but that’s exactly what we need in this case. You can configure two conditional includes in your home directory’s ~/.gitconfig file:
[user] name = Alex Pliutau email = firstname.lastname@example.org [includeIf "gitdir:~/wzln/"] path = ~/.gitconfig-wzln
[user] name = Alex Pliutau email = email@example.com
Note: To check it, make sure you are in a Git directory, non-Git directories will always show the default configuration.