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:
ssh-keygen -t rsa -C "you-mail@gmail.com" -f "you-username"
For example, to generate keys for your personal account:
ssh-keygen -t rsa -C "you-mail@gmail.com" -f "you-username"
ssh-keygen -t rsa -C "other-mail@gmail.com" -f "other-user"
Step 2: Add SSH Keys to SSH Agent
# 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
# Mac/Linux
touch ~/.ssh/config
# Windows
touch C:/Users/profile/.ssh/config
Step 5: Add the following configuration to the config file
# 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
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:
cd path/to/cloned/repo
Then, use the following commands to set your username and email:
git config user.name "Your Name"
git config user.email "your-email@example.com"
Step 8: Clone repositories
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.
---
0 Comments:
Leave a Reply