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.
You can put [user] blocks in repos, i.e.
/some/where $ head .git/config
[user]
email = [email protected]
name = My 'nick' Name
Doesn't tie into your SSH key though, if you need that.Github account switching. A git account is not an idea that makes sense.
For the use case of "use different accounts / configs for different directories", git's config has includeIf.
Feel free to have your own workflow but git already addresses this tools entire purpose with includeIf.
what does this address that includeIf does not?
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.
When did using a single per-machine SSH key on a Yubikey become so dirty in the eyes of these enterprises?
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.
[0] https://www.dvratil.cz/2015/12/git-trick-%23628-automaticall...
you can have per repo and per directory git config via git conditional includes
[includeIf "hasconfig:remote.*.url:https://*.github.com/**"]
path = /home/xani/src/gh/.gitconfigLovley, was looking for exactly that for some time. Will definitely try it, thanks for sharing!
GitHub CLI has a command - gh auth switch. It makes it really easy to switch between GitHub accounts. I also wrote a small blog/guide about it- https://aditya24raj.github.io/blogd/using-multiple-github-ac...
what does this do more than gh switch? I would rather something that automatically picks the right user based on the org
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
~/.git/config