How to use multiple GitHub accounts on the same PC

Tram Ho

Today we will learn how to use many github accounts on the same computer!

Step 1: Create a new ssh key for the work account

When the screen shows Enter file in which to save the key (/home/<user>/.ssh/id_rsa): user> Enter file in which to save the key (/home/<user>/.ssh/id_rsa): Enter the user for your job, for example I will enter id_rsa_sun

Check if id_rsa_sun was born.

List of generated files:

Step 2: Install ssh key on github

Get the id_rsa of the new email you just created.

Then enter the ssh-key of your git account at https://github.com/settings/keys

Step 3: Install Github Host

Edit your config file to:

After creating a project on github with another account. When you add remote , pay attention to user when adding. For example when clone a new repo:

You can then add and commit normally.

Add remote with new repo:

Note: sun here is my user set, you can change according to the work user or nick name you want accordingly.

Source: Git Push & Pull with Two accounts and Two users on the same machine

Share the news now

Source : viblo.asia