Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Merge code between multiple repos in the same workspace

Greetings, I'm not sure what the best strategy is but we have developers working on various aspects of software that are separated into three repos in the same workspace on Bitbucket. Let's say we want to test code and need to merge development branches from each repo into one for testing purposes. Is this possible? 

Also is there a better way to organize code if one group of developers is working on, as an example, a database and another group is working on front end UI; should this all be in one repo or is it ok to separate it out since the code could be used across multiple applications?

Thank you in advance!

1 answer

1 accepted

0 votes
Answer accepted

Hi Christian,

Merging code between multiple repos is possible from Bitbucket Cloud website only for repos that have a fork relationship. If they don't, this is not possible, as the repos have unrelated histories.

It is something you can do locally though, from your machine, the following way:

1. Assume you have repos and, and you want to merge code from repo-2 to repo-1

Navigate to your local clone of repo-1

2. Add the second repo as a remote with a command like the following (I'm adding the SSHL URL; if you don't use SSH, you can replace with the HTTPS URL:

git remote add second_remote


git fetch --all

3. Then create (in repo-1) a branch that tracks the remote branch from repo-2 you want to merge, named e.g. feature2-branch

git checkout -b feature2-branch --track second_remote/feature2-branch

4. If you wang to merge that to master branch of repo-1, then you can do

git merge master --allow-unrelated-histories

The --allow-unrelated-histories will be necessary if the repos have no common history, otherwise Git will refuse to make the merge.

I'd like to note here the following though: if you merge code like that and push it back to repo-1, this kind of defeats having 3 repos for separation of concerns, since you will be pushing code from one repo to the other. It may be better if you do this merge on the server where you run your tests only?

Regarding your second question and how to better organize code, I believe this depends on your business needs. There's pros and cons for each approach, you can take a look at the following for issues that may arise with monrepos:

and I see there are also many articles online available from different sources exploring the monrepo vs multirepo appraoch.

Kind regards,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,710 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you