Use multiple Github accounts on the same machine TL;DR

mijorus
Jun 24, 2021

The easiest and most painless solution is the following:

1. Create an SSH key for each account

# when asked, give it a unique name, like "work" or "personal"
ssh-keygen -t rsa

2. Add the key

ssh-add ~/.ssh/work

3. Create/edit an ~/.ssh/config

Edit like this

Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/personal
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/work

4. Add the key on github

Easy

5. From now on, use the SSH option when cloning, but modifing the link as follow

# Original
git clone git@github.com
:laravel/laravel.git
# Push with "Work profile"
git clone git@github.com-work:laravel/laravel.git

DONE

--

--