Tips for working with multiple GitHub accounts
I use GitHub for my work and personal projects with different profiles for
each. Because it's a good security/privacy practice, each profile has its
own distinct SSH key. However, this causes problems because the git
CLI
will always try to use the first SSH key that maps to the github.com
domain even if that key has no permissions for the target repository. The
other more straightforward problem with multiple accounts is that the
GitHub.com browser cookie asserts that you are only logged into one account
at a time.
My solutions for these problems are direnv
and Firefox
Containers, respectively. These use cases are straightforward
applications of these technologies, so I'm not claiming any innovation here,
but rather it took me a long time to identify these solutions, and I hope
this saves others some time. If you're not familiar with these tools, read
on for details.