One Git, Two Identities: How to Keep GitHub and Bitbucket From Mixing You Up

Kunal MathurKunal Mathur
2 min read

If you juggle personal projects on GitHub and company work on Bitbucket, you’ve probably run into this:
You push your work code, and Bitbucket says —

"This user cannot be matched to an Atlassian account."

Why? Because Git is still using your personal email and username from your GitHub setup.
Good news: you don’t need two laptops or endless git config switches — you just need to tell Git which identity to use per repository.

🐞 The Problem

By default, Git uses your global config, meaning:

git config --global user.name "Your Personal Name" 

git config --global user.email "you@personal.com"

So, whether you’re in your weekend side project or your company’s Bitbucket repo, Git thinks you’re the same person.


That’s why Bitbucket can’t match your personal email to your Atlassian account.

🛠️ The Fix: Set Identity Per Repo

Let’s make Git smart enough to use work details for Bitbucket and personal details for GitHub.

  1. Go to your Bitbucket project folder

      /path/to/bitbucket-project
    
  2. Set work-specific details

     git config user.name "Your Work Name" 
     git config user.email "your-work-email@company.com"
    

    💡 This writes settings to the repo’s .git/config file — leaving your global GitHub settings untouched.

  3. Check it worked

     git config user.name git config user.email
    
  4. Should show your work identity inside the Bitbucket repo.

🎁 Bonus: Automate It

If you don’t want to remember to switch every time, tell Git to auto-load a config for all repos inside a certain folder.

Edit your global Git config:

git config --global --edit

Add:

[includeIf "gitdir:~/work-projects/"] 
    path = ~/.gitconfig-work

Then in ~/.gitconfig-work:

[user] 
    name = Your Work Name 
    email = your-work-email@company.com

Now, anything in ~/work-projects will automatically use your work identity.

🚀 Final Push

With this setup:

  • Personal projects → GitHub email & name

  • Work projects → Bitbucket email & name

  • No more “user cannot be matched” errors

  • No risk of leaking personal details into work commits

💡 Tip: If you’re using SSH keys, you can also set separate keys for GitHub and Bitbucket so your push URLs never get mixed up.

0
Subscribe to my newsletter

Read articles from Kunal Mathur directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kunal Mathur
Kunal Mathur

Hi there, I am a tech-savvy full-stack developer hailing from the bustling city of Delhi. With a passion for coding and an eye for design, I have honed my skills in front-end and back-end development to deliver cutting-edge digital solutions. From building dynamic websites to developing complex applications, I have a love for exploring new technologies and a talent for problem-solving, combining my project experience to deliver effective solutions.