How to have 2 or more GitHub accounts on one machine (Windows)

Linh Nguyen My
Jan 26, 2018 · 5 min read

1. Navigate to the directory in which you want to push your changes to a different GitHub account.

2. Create a new SSH key in your terminal/command line

ssh-keygen -t rsa -C “your-email-address”
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/your_username/.ssh/id_rsa):
/c/Users/your_username/.ssh/id_rsa_IDENTIFIABLE_NAME_HERE
/c/Users/your_username/.ssh/id_rsa_test
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
ls -al ~/.ssh
total 46
drwxr-xr-x 1 your_username 1049089 0 Jan 26 10:40 .
drwxr-xr-x 1 your_username 1049089 0 Jan 23 12:12 ..
-rw-r--r-- 1 your_username 1049089 3326 Nov 30 11:21 id_rsa
-rw-r--r-- 1 your_username 1049089 748 Nov 30 11:21 id_rsa.pub
-rw-r--r-- 1 your_username 1049089 1675 Jan 26 10:40 id_rsa_test
-rw-r--r-- 1 your_username 1049089 399 Jan 26 10:40 id_rsa_test.pub
-rw-r--r-- 1 your_username 1049089 803 Nov 30 12:08 known_hosts
atom ~/.ssh/id_rsa_test.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEmSbc7ms4SNIf7G0e9EqdrQRTB17VFTqRtCbQ55sSc11xZP5B07UXf9+................a955cf1GUzsNIr60E7VuVxirrr+K2WcleqifnDEg1H/VbyJtEekh4Aav9csBwemTz3 test@test.com
ssh-add ~/.ssh/id_rsa_test
git config core.sshCommand=ssh -i ~/.ssh/id_rsa_test
git config -e
git config --global core.editor "atom --wait"

3. Set your repository to be pushed to GitHub with the associated account.

git config user.name "test"git config user.email test@test.com

4. You should now be able to commit and push.

git init
git add .
git commit -m "First commit"
git remote add origin git@github.com:your_username/test.git
git push origin master

Linh Nguyen My

Written by

A Self-taught Software Engineer @LEGO, prev @ASOS. Also interested in UI. You can find me @ pinglinh.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade