Reputation: 411
I have 5 java projects working together. At first I was working alone on these projects. Now someone joined me and we actually need to use GitHub to work efficiently.
I'm facing a design problem:
Upvotes: 3
Views: 11910
Reputation: 9
Apologies as it's not that concrete solution to it but it does the job, what I tried is I had a situation where for some reason I had to add all the projects to one repository only so I followed the following steps :
$git checkout -b <branch_name>
$ git remote rm origin (To remove remote origin)
$ git remote add origin https://github.com/<USERNAME>/<REPO_NAME>.git
$ git remote set-url origin <Access_Token>@github.com/<USERNAME>/<REPO_NAME>.git
$ git push -u -f origin <branch_name>
$ git add .
This worked for me, as whenever I want to change/pull something in any project I just clone a specific branch make changes in it and then push the changes to that specific branch only. This way you can have multiple projects under one repo. I tried this solution by myself only to bypass the tricky way of Orphan branches or having multiple Repos.
Upvotes: 0
Reputation: 131346
In fact your question could be summarized as : should I use a mono-repo approach or a multi-repo approach ?
That is broad subject but to make things simple: it depends on the coupling level and the life cycle between these projects.
You want to use a mono repo approach and add multiple projects in if these projects are designed to live and evolve together. For example, if only these projects have dependency between them and that when you change a dependency you will change the consumer, you have clearly no value to split out them in multiple repositories.
It will make global source code readability weaker and commit/pull/request/merge on multiple repositories for a same use case, which makes their readability and their consistence weaker.
You want to use a multi-repo approach and to have a project by repo in if these projects are not designed to live and evolve together. For example, if some of these projects are used by other applications than those you quote, you have no value to couple the project dependency inside the repository of the consumer project because there are other consumers, so why that consumer and not the other one ?
You have also the super mono repo approach such as that one used by Google or Facebook that adds all projects (or almost) in the same repository, whatever the level of coupling between projects. Doing such a thing is not simple and demands to custom finely the CDCI and the SCM tools to keep things practical and simple in spit of the repo size.
Upvotes: 2
Reputation: 1668
You should put each of them in its own git repository.
You then can use git submodules to add depending project to another.
Example: Project A will contain project B as submodule.
Read more about git submodules
Official documentation
Upvotes: 4