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 gitlab.com and 3rd one is at github.com with the following name “user3”
Now first generate SSK key with the following instruction : https://gitlab.com/help/ssh/README
Make sure when you will generate the SSK key then for diffrent diffrent user you have to store key at different different file like
After that create a config file at ~/.ssh/ with the follwoing command
Now you have to delete cached keys with the follwoing command
Next, you can check that your keys were added:
If you get success message then you are done with the multiple account SSH Key authentication
git config user.name "user1"
git config user.email "[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
Then for the first user of gitlab you have to replace it with its hostname define in config like
So actually domain will replace with the host like for the example I had replace “gitlab.com” with my first user host name “user1.gitlab.com”