You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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!
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:
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 email@example.com:my-workspace/repo-2.git
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.
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.