So, I have my work computer and that is connected to my GitHub Enterprise Account (github.company.com
) on the terminal. Now I want to set up my personal account (github.com
) on here too.
I've been following this tutorial - https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574
and on step 3 when I have to create my config file should my HostName
be github.company.com
or github.com
? Can I have any (meaningful) name for Host
? Also, what does User
here mean?
Also, how do I switch between both these accounts on the terminal - i.e. my personal and my enterprise account? There are certain things I need to commit from my personal account, and use the enterprise account with the rest.
Detailed steps to use two GitHub accounts on the same PC as below:
1. Create SSH key for the github.company.com account
If you already added the SSH key to your github.company.com account, then skip this step.
First, use
ssh-keygen
to createid_rsa
andid_rsa.pub
inC:\Users\username\.ssh
.Then, add the content of
id_rsa.pub file
as a SSH key in github.company.com account.2. Create SSH Key for your personal account github.com
Use
ssh-keygen -t rsa -C "email address for the personal github account"
, and save the key in/c/Users/username/.ssh/id_rsa_personal
.Now add the content of
id_rsa_personal.pub
file as a SSH Key in your personal GitHub account.3. Config the two SSH Keys
In
C:\Users\username\.ssh
diectory, create aconfig
file with below content:4. Work with the two GitHub accounts by SSH protocol
You can clone your github.company.com account by:
And then add the personal account as a remote in the local repo by:
To get the file from personal account to company repo by below commands:
To commit/push changes from local company repo by the committer of the personal repo, you just need to re-config the username and email before committing changes in the local repo:
When you want to commit changes with the company account, just re-config username and email again before committing changes.