Using Git with multiple accounts
Feb 15, 2025
Using git with multiple GitHub accounts present many problems for the user because one simply cannot use the same SSH public key for different accounts.
You can use HTTP but then you have to input your GitHub username and password everytime you have to push/pull.
We have created the guide below so you can use GitHub using multiple accounts with the easiest setup.
The steps to use GitHub using multiple accounts:
Create your new GitHub user
Here at Narra Labs, we follow a naming pattern for naming a new GitHub user. If your personal GitHub username for example iswestoque
, and you are working for a company namednarralabs
, then your new company GitHub account username would bewestoque-narralabs
.Generate a new ssh key pair for your new user using
ssh-keygen
and follow the instructions. Make sure to name the SSH key using the same pattern as your newly created GitHub username.
Two files will be generated by the command above:
The private key:westoque-narralabs
The public key:westoque-narralabs.pub
Move the new SSH key files to your
~/.ssh
directoryModify your SSH config by modifying ~/.ssh/config:
Add the line below to tell the SSH program that you have a new host using the following configurations.Clone the project using your new host:
The original GitHub SSH clone link would look like below:
You then have to modify it using your new host:
Then clone the project:You can now push/pull like normal for this specific repository.
You can repeat the steps above for another GitHub account.