How To Use Multiple Git Account On The Same Computer


Git (/ɡɪt/) is a widely used source code management system for software development.Sometime developers need to use more than one git account at a time.Here in this post we will show you how to use Multiple Git Account.

How To Use Multiple Git Account 

Like you have 3 users one is “user1” and 2nd one is “user2” at and 3rd one is at with the following name “user3”

Now first generate SSK key with the following instruction :

Make sure when you will generate the SSK key then for diffrent diffrent user you have to store key at different different file like

IdentityFile /Users/user1/.ssh/id_rsa
IdentityFile /Users/user1/.ssh/id_rsa2
IdentityFile /Users/user1/.ssh/id_rsa3

After that create a config file at ~/.ssh/ with the follwoing command

cd ~/.ssh/
touch config
nano config

And in config just add the following settings

Now you have to delete cached keys with the follwoing command

ssh-add -D

Next, you can check that your keys were added:

ssh -T [email protected]
ssh -T [email protected]
ssh -T [email protected]

If you get success message then you are done with the multiple account SSH Key authentication

Now for every project you have to define your username and user mail with the following command

cd ~/project_location
git config "user1"
git config "[email protected]"

Adding Remote path

When you will add your remote path from any project eigther github or gitlab in your local git project then you must have to follow a tricks to make it works with the different different user like If you get your remore repository url like this
[email protected]/main-site-master.git

Then for the first user of gitlab you have to replace it with its hostname define in config like

[email protected]:user1/main-site-master.git

So actually domain will replace with the host like for the example I had replace “” with my first user host name “”

Hope its now clear 🙂


  1. 1

Leave a Reply