Expert IT Solutions

Discover New Ideas and Solutions with CodeEssence Blogs

Get inspired with our insightful blog posts covering innovative solutions, ideas, and strategies to elevate your business.

shape image
shape image
shape image
shape image
shape image
shape image
shape image
image

Setting Up Multiple GitHub, GitLab, and Bitbucket Accounts on One System

In the realm of software development and project management, handling multiple accounts across platforms like GitHub, Bitbucket, and GitLab is essential. This comprehensive guide provides a step-by-step approach to setting up and managing user accounts seamlessly, ensuring smooth collaboration and efficient workflow across these popular platforms.

 

Step 1: Generate SSH Keys

Open a terminal/command prompt.

Generate SSH keys for each Git account using the following command:

Bash
ssh-keygen -t rsa -C "you-mail@gmail.com" -f "you-username"

For example, to generate keys for your personal account:

Bash
ssh-keygen -t rsa -C "you-mail@gmail.com" -f "you-username"

 

Bash
ssh-keygen -t rsa -C "other-mail@gmail.com" -f "other-user"

 

Step 2: Add SSH Keys to SSH Agent

Bash
# Linux/Mac
ssh-add -K ~/.ssh/your-username
# Windows
ssh-add C:/Users/profile/.ssh/your-username
# Repeat for other account keys

 

Step 3: Copy the .pub key of your desired username and paste it on your GitHub/Bitbucket/GitLab account

You can add it here for GitHub.

Step 4: Configure SSH Alias for GitHub

Bash
# Mac/Linux
touch ~/.ssh/config
# Windows
touch C:/Users/profile/.ssh/config

 

Step 5: Add the following configuration to the config file

Bash
# First account
Host github.com
    HostName github.com
    IdentityFile ~/.ssh/your-username
    IdentitiesOnly yes
# Other account
Host code
    HostName github.com
    IdentityFile ~/.ssh/other-username
    IdentitiesOnly yes

 

Step 6: Test the SSH configuration

Bash
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh -T git@config alies first
ssh -T git@config alies other

You will see messages like:

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

 

Step 7: Update Git User Config for Cloned Repositories

If you haven't already, set your Git username and email for each cloned repository. Navigate to the repository's directory using the terminal/command prompt:

Bash
cd path/to/cloned/repo

Then, use the following commands to set your username and email:

Bash
git config user.name "Your Name"
git config user.email "your-email@example.com"

 

Step 8: Clone repositories

Bash
git clone git@config alies:username/repo.git

 

Now, you are all set up to handle multiple Git accounts seamlessly. Remember to update the cloned repositories with your Git username and email to ensure proper authorship and integration with your accounts.

---

3 Comments:

Leave a Reply

Your email address will not be published. Required fields are marked *