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:
|
|
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:
|
|
~/.gitconfig-work:
|
|
Note: To check it, make sure you are in a Git directory, non-Git directories will always show the default configuration.