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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 30, 2020

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 https://bitbucket.org/my-workspace/repo-1/ and https://bitbucket.org/my-workspace/repo-2/, 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@bitbucket.org:my-workspace/repo-2.git

then

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,
Theodora

Ganesh Raj Manandhar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Oct 15, 2023 • edited

Hi Theodora,

Since it was stated that "Merging code between multiple repos is possible from Bitbucket Cloud website only for repos that have a fork relationship". Can you give a work through on how to achieve this.
Our use case:
1. Repo B is a forked from Repo A.
2. There's a bitbucket-pipelines.yml in repo B.
3. Need to merge branch from Repo A i.e branch A into repo B's branch i.e branch B.

So, is it possible to do so by writing scripts in the .yml file itself? the idea was to add remote of repo A in the yml and then do the fetching/merge using the remote but it's not working.
Any other solutions are welcome as well.


Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events