How to manage multiple Github accounts

For the developer who is dealing with more than one Git account.

saish chachad
make it heady
4 min readMar 29, 2020

--

The following steps will help with carefully and efficiently managing multiple Git accounts. Simply copy and paste the commands onto your terminal and check the code from your repository.

Step 1. Check for existing SSH keys

  1. Open Terminal app.
  2. Enter ls -al ~/.ssh to see if existing SSH keys are present. List the files in your .ssh directory, if they exist.
  3. Check the directory listing to see if you already have a public SSH key.
  4. By default, the filenames of public keys are one of the following:

Tip: If you don’t have an existing public and private key pair, or prefer not to use any that are available to connect to GitHub, you can generate a new SSH key.

Step 2. Create new SSH

Step 3. Add your private SSH key to the ssh-agent and store your passphrase in the keychain

Step 4. See the list of added SSH

This will list the fingerprints of all identities.

Step 5. Add a new SSH key to your account

Tip: If pbcopy isn’t working, you can locate the hidden .ssh folder by opening the file in your favorite text editor and copying it to your clipboard.

  1. Go to your Github account.
  2. In the upper-right corner of any page, click your profile photo, then click Settings.

3. In the user settings sidebar, click SSH and GPG keys.

4. Click New SSH key or Add SSH key.

5. In the Title field, add a descriptive label for the new key.
Paste your key into the Key field.

6. Click Add SSH key.

7. Follow the same steps to copy id_rsa_work and id_rsa_work2 key onto your work and freelance accounts.

Step 6. Make changes in the config file

  1. Go to .ssh folder.
  2. Open config file in any textEditor.
  3. If config file is not present, create one.

Step 7. Copy and paste this text into the config file

In my case, my personal and freelance accounts are on GitHub, and my work account is on VSTS.

Step 8. Clone Repo (Freelance Github Account)

Copy the clone URL from Github (from work2 account) and modify as below.

Original url:

Modified url:

Paste this (modified) URL onto the terminal.

Step 9. Configure User attributes

Go into the repository folder from terminal and paste this command.

Step 10. Repeat steps 8 and 9 for other (personal and work) accounts

Cheers 🥂

Extra Commands for HELP

  1. Delete all identities.

2. For more help, use the following commands.

P.S : We’re hiring at Heady! 👋 If you would like to come work with us on some really cool apps please check out our careers page.

--

--