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

Software Developer (Full Stack) with 4 years of experience building scalable web applications across frontend and backend. Focused on performance, security, and clean architecture. Skilled in troubleshooting, agile collaboration, and delivering production-ready solutions. Driven by continuous learning and delivering high-value, user-centric solutions.
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.
Go to your Bitbucket project folder
/path/to/bitbucket-projectSet 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.
Check it worked
git config user.name git config user.emailShould 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.



