You can extend this trick further by specifying the User in your SSH config to make for even shorter URLs.
Host gh-me
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa
Host gh-work
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_work
Then all you need is a `git clone gh-me:org/repo` or `git clone gh-work:work/repo`. I've been using this for sometime and it's not too hard to remember. Although when I don't it's easy enough to fix the origin url by editing `.git/config`.
Re:Setting up Git identities
by unityByFreedom on Tuesday March 24, 2020 @03:33AM
(#22672826)
Yeah I also sometimes forget to use the proper URL, I wish it were a little easier to setup and use the concept of separating work/personal or public/private repositories.
I've been using the same account for both work and personal repos, without much issue due to the existence of github organizations.
What sorts of separation are beneficial for you? I'm wondering if I should switch, but I don't fully understand.
Depending on the employer and the side-project, using the same account for both could _in theory_ bolster a (ridiculous, absurd) ownership claim over your work, for example. Stranger things have happened.
More pragmatically, I've been burned in the past by using personal accounts (not GitHub specifically) for work things. For example, I used a personal commuter card for a former job's benefits program. When I left, they deactivated my card. Awkward! Not the same kind of risk with GH, to be sure, but after that I do prefer to keep my digital selves as compartmentalized as possible.
I've been using variations on this technique for a few years now. It's kind of a pain to remember which URL to use to clone a repo, but is great for keeping that veneer of separation between work and personal projects.