Git config with Multiple Email Addresses

I am working on open source project and my company project. So I need to have multiple email for git commits. If I start working on my company project, I have to change my git config email by running git config --global On the other hand, if I start working on open source project, I have to run git config --global

Sometime I forgot to follow the above step for git configuration, and this create problem for me. In following steps, I am going to explain how to setup git config globally and locally for each project.

In this tutorial I will cover:

  • Where the git config located both globally and locally.
  • How to config git locally and globally.

1- Set Git config Globally


git config --global "Your Name"git config --global "Your Email"

It will save the config in to $home/.gitconfig file.

Git config Globally

Note : By default, all project gets the config globally if it had not been setup locally.

2 — Set Git Config Locally

By default, all project get the config from global config file which is in above image, but it can be set it locally. To setup locally run the following commend.

git config "Your Name"git config "Your Email"

It will save the config in to .git/config file of the project.


Git configuration can be added in system level as well which can be used for all other users.

:) Thanks for the reading and Happy coding.

An enthusiastic Full Stack Developer who has a long record of developing, implementing, and testing software to meet specific project requirements.