github accounts
2020 30 Dec

Manage multiple GitHub accounts like a pro!

Oftentimes it may happen that you have a Github account where you upload all your code for practice sessions or learning purposes. You have another Github account pertaining to your company profile. When you push your changes, be it to your own Github account or a project-specific, how do you make sure that the respective account is always used? Well, I am here to help!


Set up SSH Keys

Let’s assume your two Github accounts are named githubPersonal and githubWork, respectively.

Create two SSH keys, saving each to a separate file:

mgh 1 img

Save it as id_rsa_personal when prompted.

mgh 2 img

Save it as id_rsa_work when prompted.

The above commands set up the following files:

- id_rsa_personal


- id_rsa_work


Add the keys to your Github accounts

Copy the key to your clipboard:

mgh 3 img

In case you do not have pbcopy installed. To install and use pbcopy:

mgh 4 img

Edit your bash file

mgh 5 img

Create alias

mgh 6 img

Refresh your bash

mgh 7 img

Add the key to your account:

  • Go to your Account Settings.
  • Click “SSH Keys” then “Add SSH key”.
  • Paste your key into the “Key” field and add a relevant title.
  • Click “Add key” then enter your Github password to confirm.

Repeat the process for your githubWork account.

Create a configuration file to manage the separate keys

Create a config file in ~/.ssh/

mgh 8 img

Edit the file using the text editor of your choice, here I am using nano, which is readily available in Linux.

mgh 9 img

Paste the following in the config file:

mgh 10 img

Update stored identities

Clear currently stored identities:

mgh 11 img

It will show all identities removed

Add new keys:

mgh 12 img

Test to make sure new keys are stored:

mgh 13 img

Test to make sure Github recognizes the keys:

mgh 14 img

You should see something like this:

mgh 15 img

mgh 16 img

You should see something like this:

mgh 17 img

One active SSH key in the ssh-agent at a time

To keep things safe, we need to manually ensure that the ssh-agent has only the relevant key attached at the time of any Git operation. So that the active ssh key is used at the time of push

ssh-add -l will list all the SSH keys attached to the ssh-agent.

Clear currently stored identities:

ssh-add -D

Add the required ssh key

Change config name and email for a project

GitHub identifies the author of any commit from the email id attached with the commit description.

First, check the name the project is using:

mgh 18 img

Check the email the project is using:

mgh 19 img

If you need to change then do the following:

mgh 20 img


Latest Blogs

benefits of mobile apps for business

What are the Benefits of Mobile Apps for Businesses

Mobile applications are ruling over our world, whether it is about shopping, health, entertainment or something else. We cannot imagine our single second without using mobile apps.

Read More

Healthcare mobile app development

How Healthcare Mobile Apps is Booming the Healthcare Sector

No one can deny that mobile apps have revolutionized all sectors, whether eCommerce, education, or mobile healthcare apps. There is hardly any sector untouched by the blessings of mobile apps.

Read More

Mobile UX design

Top Do's & Dont's for a Perfect Mobile User Experience Design

In any situation, the first impression is considered the last impression. The same is the case in the world of mobile applications.

Read More

Mobile app development trends

15 Effective Mobile App Development Trends That Will Boost

The mobile app development industry is continuously evolving with great speed. There is indeed tough competition in this industry.

Read More