How to Use Multiple GitHub Accountsby@terieyenike
245 reads

How to Use Multiple GitHub Accounts

by TeriMarch 29th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

GitHub allows you to create multiple accounts that can be used for different purposes. You need to have git on your local machine to create multiple GitHub accounts. You must create a secure shell (SSH) key and an email address for each account. You also need to add the public and private keys to your account.
featured image -  How to Use Multiple GitHub Accounts
Teri HackerNoon profile picture

Is it possible to have multiple GitHub accounts that you can use for different purposes? Yes, it is, and you can do so easily with as many GitHub accounts as possible.

I found it challenging when I created another account on GitHub and discovered it was not possible to use the same git configuration for the first account on setup without doing something extra to talk with the new GitHub account.

My primary GitHub account is, and the second account is

Note: To create another account with the same email address, use plus(“+”) sign like this: [email protected]


The following setup is required to follow through:

  • Have git on your local machine. Download it for your operating system (OS)
  • You already have an account on GitHub. Sign-up is free
  • Terminal


Note: I will work on macOS for all the actions in this tutorial.

Let’s get started with these steps:

Step 1

Create secure shell (SSH) keys Make sure the .ssh directory is present in your home directory with this command:

cd ~/.ssh

Writing this command in your terminal, learn how to use bash.

To check you have this hidden folder, type:

ls -a

This command above lists all the folders present on your system.

If otherwise, create it with this command:

touch .ssh

Next, generate a unique ssh key for this account:

ssh-keygen -C "<email-address>" -t rsa -f "<name-of-file>"

After pressing the enter key, the terminal will ask for a passphrase; you can leave it empty and accept the defaults.

ssh-keygen: a tool for creating the authentication key pair for SSH -C: represent comment to identify the ssh key -t: is the type of key created using rsa -f: name of the file for storing the keys <email-address>: The email address for your GitHub account <name-of-file>: use any name of your choice

Note: change the placeholders in the <> symbol

The command will generate the public and private keys. The public key will have an extension .pub, and the private key will be the same name without the extension. The private key is not to be shared and kept secret.

Use this command, ls -l, to view the generated keys.

public and private key

Step 2

Add SSH keys to the SSH agent Before using the keys, you will need to add the private key to the SSH agent in the terminal:

ssh-add ~/.ssh/developedbyteri

Step 3

Add SSH key to your account In this section, you will add the generated public key pair to your GitHub account. Use this command.

Copy the public key

pbcopy <

This command will copy the public key to the clipboard.

public key


You can choose to use either vim or nano keyword to reveal the public key and copy it:

vim ~/.ssh/

nano ~/.ssh/

Paste the public key to GitHub

  • Sign in to your GitHub account

  • Click on your profile in the upper right corner of the page and select Settings

  • Select SSH and GPG keys and create a New SSH key, respectively

  • Paste the copied public key, not the private key, and give the key a title

ssh key github

Step 4

Modify the config file Create a config file.

But first, if the file doesn’t exist, use this command to create one in the ~/.ssh directory:

touch config

Use this command to open the file in your default text editor (TextEdit, VS Code):

open config

If you want to use VS Code to open this file, use the command:

code config

Now, copy-paste this:

          User git
          IdentityFile ~/.ssh/developedbyteri

Note: Change the values to both your GitHub username and private key name, respectively

Step 5

Fork and Clone a repository With all the setup done from the previous steps, let’s fork and clone a repository using the newly created GitHub account, which differs from your main account.

In this section, you will contribute to an open-source project from this repository,

Fork this repository Open the link above, and click on the fork button to create an entirely new copy of a repository in your account.

fork a repo

After that, click the Create fork button. You can always change the Repository name or the Description if you desire.

create fork

Next, click the green Code button dropdown and copy the URL using HTTPS, SSH protocols or the GitHub CLI. Choose one.

I will be using the SSH protocol.

Cloning Cloning creates a local copy of the repository on your local computer. Check out the official docs of GitHub on cloning.

Back to your terminal, clone the repository to a desired location on your local machine using this command:

git clone [email protected]:{username}/{repository-name}.git

git clone [email protected]:developedbyteri/cloudinary-upload.git

clone repo

Step 6

Let’s work on the cloned repository by navigating to the directory with this command:

cd cloudinary-upload

Open the folder in VS Code:

code .

In the folder, click on the file. I will edit this file just for an example.

Stage and commit the file Use this command below to stage and commit the file locally.

Note: You can stage the name of the single file you changed or the entire project using the command git add .

git add

git commit -m "Add: include the name of the hackathon"

-m: adds a commit message for the changes made to the file

Final step

Before pushing this code back to GitHub, let’s configure this directory with the user email and name to track its changes on this account.

To do this, use the following commands:

git config "[email protected]"

git config "Codegod"   

Note: Always remember to use this command for different accounts from the primary one.

Push the code This command will push the code to the remote repository.

git push

Go back to your account. The repository will update with the message “This branch is 1 commit ahead …”; click on it.

1 commit ahead

With the file open, click the green button, Create pull request and inspect this file. You should see the highlighted message in green you added earlier in VS Code.

create pull request

Next, click the Create pull request button, and it opens to check the branch for conflicts. Once it passes, it shows a green check mark to signify everything is okay with your changes.

pull request passed


Now that you know, you can have as many GitHub accounts as possible and use these steps to add, update, and modify code in any GitHub accounts you choose without any issues.

If you found this article helpful, share it with someone who might benefit, as I struggled with it until I found a hack and solution.

Further reading