Reputation: 7580
In a single project I have to organize multiple parts of the project. A web app written in php, api server written in nodejs and android and ios apps. Would it be good idea to separate these in to multiple repos? Or separate folders in a single git repo?
Upvotes: 4
Views: 3552
Reputation: 152027
I've tried the "one repo per part" approach for a project that consisted of a frontend web app, a backend one, a Chrome extension, a website, and a few shared libraries. This was dictated primarily by the fact that the libraries are open sourced on GitHub, while the rest of the code is proprietary.
While this obviously worked great for the open sourced libraries, it turned out to create several problems for the private repos:
git pull
in each directory that was a dependence of the current project (frontend/backend/etc.)The only good use cases I've found for this pattern:
Upvotes: 2
Reputation: 17631
If you plan to re-use those separate "projects" you should use a git submodule. However if you don't, I would simply separate them in different folders under one unique git.
git submodules are great for projects that can be "cloned" and keep up to date in any other (bigger) projects.
Be aware that it is adding some complexity layer when dealing with submodules.
Upvotes: 2
Reputation: 6129
I would keep those as separate projects. If you need to combine git repos you can always use git submodules.
Upvotes: 0
Reputation: 9097
If the single modules are reasonably independent you can use git submodule to mingle the two approaches. You would end up with a single folder/repo in which a you have a folder for each sub-project. Every sub-project is a separate repository and can be used as such, but you would gain the ability to track the version of each project from the root repository as well as issuing "joint" commands to the sub-modules as in
git submodule update
or "recursive" commands, as in
git submodule foreach make
you find the documentation and some sort of tutorial online.
Here is an example of setting up a repository containing several submodules (ncs, ..., test_network)
git init
git submodule add ssh://.../ncs
...
git submodule add ssh://.../test_network
vim Makefile #write the Makefile for the whole project
git add Makefile
git commit -i -m "Makefile added"
git submodule foreach autoreconf -i
git submodule foreach ./configure
make test
Upvotes: 3