How to push to a work repo and personal repo with separate GitHub accounts

Sometimes I just want to work on some side projects on my work laptop for personal learning and still light up my personal GitHub account squares with my personal Github account.

I used a mix of a tutorial and a Stack Overflow answers and this is what worked for me.

Step 1 — Create a New SSH Key

cd ~/.sshssh-keygen -t rsa -C ""Generating public/private rsa key pairEnter file in which to save the key (/Users/administrator/.ssh/id_rsa): /Users/administrator/.ssh/id_rsa_personalEnter passphrase (empty for no passphrase)Enter same passphrase again:Your id has been saved in .....

Step 2— Enter SSH Keys into Personal Github Account

Log into personal github account, go to account settings, go to SSH Public Keys, set the title to whatever, and paste in Key from whatever is stored in your .ssh directory


copy the whole string from there, then paste it into the SSH Public Key section, click Add Key

Step 3 — Let SSH know about your newly created rsa

ssh-add ~/.ssh/id_rsa_personalIdentity added: ....

The bulk of the work has been done…

Step 4 — Create or edit a config file

cd ~/.ssh# touch or edit config filevim config

For me, this popped up

Host *  AddKeysToAgent yes  UseKeychain yes  IdentityFile ~/.ssh/id_rsa

Then I changed it to:

Host  HostName  User git  IdentityFile ~/.ssh/id_rsaHost github-personal  HostName  User git  IdentityFile ~/.ssh/id_rsa_personal

Step 5: Create a local directory on your machine

cd into the local directory you created then do:

git init

Here, type to see what the user email is set to

git config 

Most likely, it should be set to the default GitHub account, in my case, the work email.

Now do this:

git config ""

Step 6: Create a repo on personal Github account

After that, there’s some tweaking you have to do…

Step 7: Remote adding tweaks

Usually, your git remote add convention will be just copypasta this:

git remote add origin

But…now it will be something like this

git remote add origin git@github-personal:kevinYCKim33/effective-journey.git

Now when I do:

git push -u origin master

I will now be able to push to my personal repo under my personal email.

I am still able to push to my work repo with my work account without needing any git remote tweaks.


TLDR: If I need to create a personal project on my work mac, all I have to do is follow Step 5~7 at this point. Then push to everything as needed, and all of that right repo with right person thing should be taken care of.


Quick Tip: How to Work with GitHub and Multiple Accounts: 90% here but it defaulted to letting me push to my personal repo with my work account.

Greg Leszek answer but with quotes around “”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store