my image

nivethan ariyaratnam

Senior Software Engineer @ Allion Technologies, writing daily events, interesting finding, thoughts here

2025-11-05

Simplest Guide to Manage Multiple GitHub/Bitbucket Accounts

Switching between projects is no fun. esspecially when the code base is not inside your organization and you supposed to use a different Github/Bitbucket account to push your code and have an existence out of your work! but the simplest solution i was able to find is this stackoverflow post and this blog. while the setup is easy to do i hate that everytime i work on a project i need to worry about the remote url. i need to setup the remote url in specific way so i can push it, every damn time! instead of solving problems i need to constantly worry about this? so i decided to find a one time solution which you or I will never even think about it. i’m not going to tell you about how to generate ssh key and how to add it on github etc. its already well documented.

prerequsites

Add SSH keys to your Github Accounts and/or Bitbucket Account

Solution

My idea is have a global config with my personal account and have dedicated folders for each account of work

# ~./gitconfig

# personal account for global
[user]
	name = nivethan-me
	email = 11111111+test@users.noreply.github.com

[core]
	editor = nvim
	excludeFile = /Users/nivethan/.gitignore
  sshCommand = ssh -i ~/.ssh/id_ed25519

[init]
	defaultBranch = main
[color]
	ui = true

# Github account for work
[includeIf "gitdir:/Users/nivethan/Developer/allion/"]
  path = /Users/nivethan/Developer/allion/.gitconfig

# Bitbucket account for work
[includeIf "gitdir:/Users/nivethan/Documents/"]
  path = /Users/nivethan/Documents/hcsl/.gitconfig