How to configure multiple accounts on git?

Posted January 9, 2021 348 views

As I was following the tutorial
I wanted to know, how can we configure multiple usernames?
Reason: Say one project is personal and requires and other one is professional and requires How can I achieve the same?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @yashtibrewal,

In order to set up your Git username for a single repository, you need to skip the --global flag and run the command inside the specific repository.

Let’s have the following example if you have 2 repositories: project1 and project2.

  • First go to the project1 directory:
cd project1
  • Then set a Git username:
git config "Your Name"
  • Then you could also check if it has been setup correctly:
git config
  • To set your email run:
git config ""

Once you are ready with project1 use the cd command to access the project2 repository and run the config command again.

Hope that this helps.