10 Jan

Configure multiple Github accounts on Mac

You may run into a situation where you need to work with multiple Github accounts possibly your personal account and office account. You may very well have one account up and running, but how do we setup another account to work on same machine. Let’s see how to do that.

1. Generate a new ssh key : Create a new and unique ssh key for your secondary Github account

Make sure you do not overwrite your old ssh file. You can save the file as “id_rsa_office”.

2. Attach the generated key to ssh:

if you have done everything right you should get a message “Identity Added.”

3. Attach the generated key to your Github account: Login to your Github account and in account settings sections click the “SSH Keys” tab and add ssh key.
add ssh key to github

 

To read the content of key just open the key you created in step 1 and paste its content in the “key”  text area. Use the following command to read key contents.

Give a name to your key and click “Add Key” button.

4. Create the configuration file: Now we need to configure ssh to tell when to push changes to our office account or personal account.
Create config file:

Open config file and paste the following content in file:

This is the default configuration for your primary Github account. Now add the configuration for your office account. Paste following line of code just after the previous content.

This time we have provided the configuration for our office account.
5.  Test it out:  Now try to push changes to your office git account using new configuration. Create a test folder and initialize git and add a test commit
 Create a new git repository in your office account with name “test”. Now try pushing changes to this repository.

In order to push changes to respositery in your personal account you first need to remove old origin and then add the new origin.

Thats it. Now you have successfully setup multiple Github accounts on your system. :)

The following two tabs change content below.

Vineet Garg

Sr. Web Developer at GuestHouser
I am passionate about technology and web development.

Latest posts by Vineet Garg (see all)

  • http://www.populationofindia.in Abhay Singh

    Meaningful contents….best of luck..

    • techigniter

      Thanks :)

  • http://www.waytomanali.com Abhay Singh

    Nice Contents…..