Skip to content

Instantly share code, notes, and snippets.

@isteves
Last active July 19, 2020 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isteves/88e3b4a4de7c64e1c1e0223cf07cf55f to your computer and use it in GitHub Desktop.
Save isteves/88e3b4a4de7c64e1c1e0223cf07cf55f to your computer and use it in GitHub Desktop.
Dealing with two GitHub accounts

Dealing with two GitHub accounts on one computer

I keep messing this up, so documenting what I currently remember here. If future Irene arrived here because of a bad commit, this is how you undo the latest commit: git reset HEAD~ (SO post)

To start, I set up my work and personal accounts with separate SSH keys (id_rsa files, etc) using this guide.

I'm never clear on what's going on behind the scenes in the RStudio git pane, so I tend to use the terminal when using my secondary (personal) account. Each time I open a new personal project, I need the following steps.

  1. When cloning the repo, add "personal" to the URL (this is how I have it set up): git@personal.github.com:isteves/my_repo.git
  2. After cloning and creating a new RProject, run ssh-add ~/.ssh/id_rsa_personal in the terminal to switch to the personal account. Run git config user.email or git config --list to check/change credentials for good measure
  3. The git pane can be used for adding files, but I use the terminal for committing & pushing (have yet to confirm if this makes a difference).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment