Using Github with multiple accounts on a single computer

I have two github accounts, one personal and one for work. I like to keep my work account clean, so if I need to patch an upstream project, I use my personal account.

First, setup a second SSH key

ssh-keygen -t rsa -b 4096 -f ~/.ssh/github-mypersonalgh

Add the to Github (in Settings/SSH and GPG keys)

Add some magic to your .ssh/config file:

  User git
  IdentityFile ~/.ssh/id_rsa

  User git
  IdentityFile ~/.ssh/github-mypersonalgh

Then clone with a special remote url:

git clone

Finally, inside the project, set the local config

git config "My Name"
git config "[email protected]"


Date: 2019-08-17

Tags:  git