Solving the problem of having a personal and a work GitHub account is really trivial without any extra tools. All you need is a dedicated SSH key for that GitHub account. (And why would you have a password for a ssh key on your personal machine?)
~/.ssh/config
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/work_id_rsa
IdentitiesOnly yes
The host shenanigans are simpler addressed with `git config core.sshCommand` which overrides the default key and selects the desired one on a per repository level.
I used to have a git post-checkout hook that set the repo identity based on the repo origin url [0] on checkout - maybe there's some post-clone hook these days, but 10 years ago when I wrote it there was only post-checkout hook.
This is nice! This was a problem I faced a few years ago at my job. What I did was create a custom Bash function to switch Git accounts and add it to my .bashrc file. I love this. I’ll give it a try.
For the folks looking at tools to help manage personal and work identities on the same computer: don't.
Never access personal accounts from a work computer or work accounts from a personal computer under any circumstances.
This goes for laptops, desktops, and especially cellphones.
If an employer asks that you violate the above, ask for a dedicated device owned by your employer to access a work account. If they refuse, that's a big red flag. "Oh just use your phone to check your email/slack" - 1. don't assume everyone has a cellphone and 2. if you want folks doing work on a device, pay for it.
Managing multiple personal accounts on computer A or multiple work accounts on computer B is totally fine.
As an aside, company general counsels might be shocked at how often their employees log in to slack/email/etc. from their personal cellphone: suddenly any and all company and customer intellectual property has a way to leave the network. And it's not even a "pull" from the employee as the other employees just "push" them messages.
17 comments
[ 2.9 ms ] story [ 39.2 ms ] thread~/.ssh/config
~/.git/configsource: https://erik.doernenburg.com/2017/12/using-multiple-github-a...
[0] https://www.dvratil.cz/2015/12/git-trick-%23628-automaticall...
what does this address that includeIf does not?
Never access personal accounts from a work computer or work accounts from a personal computer under any circumstances.
This goes for laptops, desktops, and especially cellphones.
If an employer asks that you violate the above, ask for a dedicated device owned by your employer to access a work account. If they refuse, that's a big red flag. "Oh just use your phone to check your email/slack" - 1. don't assume everyone has a cellphone and 2. if you want folks doing work on a device, pay for it.
Managing multiple personal accounts on computer A or multiple work accounts on computer B is totally fine.
As an aside, company general counsels might be shocked at how often their employees log in to slack/email/etc. from their personal cellphone: suddenly any and all company and customer intellectual property has a way to leave the network. And it's not even a "pull" from the employee as the other employees just "push" them messages.