Skip to content

Instantly share code, notes, and snippets.

@bathivinod
Last active June 13, 2025 18:30
Show Gist options
  • Select an option

  • Save bathivinod/2e623dd1f50358e6d72df16e7ef8758b to your computer and use it in GitHub Desktop.

Select an option

Save bathivinod/2e623dd1f50358e6d72df16e7ef8758b to your computer and use it in GitHub Desktop.
This repo is used to setup multiple git accounts

Multi-Git Account Setup on Windows (GitHub + Bitbucket)

This repository demonstrates how to configure and manage multiple Git accounts (GitHub and Bitbucket) on a single Windows machine using separate SSH keys and SSH host aliases.

🔐 Git Accounts Used

  • GitHub

    • Email: abc@gmail.com
    • SSH Key: ~/.ssh/id_rsa_github
  • Bitbucket

    • Email: xyz@vinhost.com
    • SSH Key: ~/.ssh/id_rsa_bitbucket
    • Repository: vinhost/vh-ecommerce

⚙️ Step-by-Step Setup Guide

1. Generate SSH Keys

# GitHub
ssh-keygen -t rsa -b 4096 -C "abc@gmail.com" -f ~/.ssh/id_rsa_github

# Bitbucket
ssh-keygen -t rsa -b 4096 -C "xyz@vinhost.com" -f ~/.ssh/id_rsa_bitbucket

2. Add SSH Keys to SSH Agent

eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa_github
ssh-add ~/.ssh/id_rsa_bitbucket

3. Add Public Keys to Git Services

GitHub

Bitbucket

4. Configure SSH with Custom Host Aliases

Create or edit ~/.ssh/config:

# GitHub
Host github.com-abc
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_github

# Bitbucket
Host bitbucket.org-xyz
  HostName bitbucket.org
  User git
  IdentityFile ~/.ssh/id_rsa_bitbucket

5. Cloning Repositories

GitHub Example

git clone git@github.com-abc:your-username/your-github-repo.git

Bitbucket Example

git clone git@bitbucket.org-xyz:vinhost/ecommerce.git

6. Per-Repository Git Config

Set identity info for each repo:

# Inside GitHub repo
git config user.name "Your Name"
git config user.email "abc@gmail.com"

# Inside Bitbucket repo
git config user.name "Your Name"
git config user.email "xyz@vinhost.com"

7. Verification

To test which key is being used:

ssh -T git@bitbucket.org-xyz
ssh -T git@github.com-abc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment