I mentioned my crappy approach to using multiple GitHub accounts on a Slack I’m on, and someone else pointed out there’s a much easier approach: Instead of using wrapper scripts to set up different environments, you can fake it using
First, set up key rules with
Next, set your origin based on whether the workspace is work or personal; for example,
git clone git@github-work:work-org/project.git (and of course you can
git remote set-url origin for existing workspaces).
Finally, to handle the different author name and email, git 2.15 and later support conditional includes. If you keep all of your work projects in a separate directory, you can put this into your
.gitconfig-work includes your work-specific configuration, e.g.: