Different GitHub Accounts
Problem Description
Since I try to keep some online identities separate, I often stumble into problems like “Which email alias did I use for this service?”
This time a new problem popped up when I created a second GitHub account. I want to git push
via SSH key and each account should have its own key (not sure why, but it feels correct).
Solution
Gist: Create a ssh config file that references different keys for different hosts. One Host
can just be the default github.com. The other Host
must be matched in ~/clonedRepo/.git/config
So the resulting files on my local machine look like this:
~/.ssh/config
|
|
~/clonedRepo/.git/config
|
|
The part after the @
is the same as the Host
in the ssh config. Note the user in front of the @
is always git
.
Sources
Following resources helped me to figure it out
- YT - How to Work with GitHub and Multiple Accounts
- found in comment of SO - Multiple GitHub Accounts & SSH Config
Boom, it works.