How to setup two GitHub on one device? Using Git
As a professional in software development field you often have one work Github which you have on you work email but you can’t really have your own projects their. So you need access to your personal Github as well where you can have your own personal projects and activity. To do so you need to setup your both GitHub accounts using Git Command Line.
STEP 1:
For each of your account get your SSH key for authentication. To do so go to Setting > Developer Settings > Personal Access Token > Tokens(Classic)
Make sure to copy the token you have generated as it won’t be shown again.
Now have both saved for a while we’ll use them later.
STEP 1:
First of all create two projects Work and personal once created now create their respective Github repositories on each account.
STEP 2:
Now go to your local project repository lets go with the work project first.
1->Run following commands to create user
git config user.name “Work github username”
git config user.email “your.workemail@example.com”
You will have to run these in all projects new and existing.
2-> start running commands provided on Github page once you create an empty project once you reach push command you will be asked for authentication.
3-> Now login using SSH key for email. Make sure to not mix up otherwise you will face issue with the permissions.
Step 3:
Now got your local project repository for personal project.
1->Run following commands to create user
git config user.name “Perosnal github username”
git config user.email “yourPersonalGithubEmail@example.com”
You will have to run these in all projects new and existing.
2-> start running commands provided on Github page once you create an empty project but make sure to use commange “git remote set-url origin https://github.com/userName/projectName.git” instead of “git remote add origin https://github.com/userName/projectName.git”. Now continue as before. Once you reach push command you will see error. Now run command
3-> Now login using SSH key for email. Make sure to not mix up otherwise you will face issue with the permissions.
I hope its helpful for you.