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


⚙️ Step-by-Step Setup Guide

1. Generate SSH Keys

# GitHub
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_github

# Bitbucket
ssh-keygen -t rsa -b 4096 -C "[email protected]" -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 [email protected]:your-username/your-github-repo.git

Bitbucket Example

git clone [email protected]: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 "[email protected]"

# Inside Bitbucket repo
git config user.name "Your Name"
git config user.email "[email protected]"

7. Verification

To test which key is being used:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment