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

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

The bulk of the work has been done…

Step 4 — Create or edit a config file

For me, this popped up

Then I changed it to:

Step 5: Create a local directory on your machine

cd into the local directory you created then do:

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

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

Now do this:

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:

But…now it will be something like this

Now when I do:

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