Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good way of organizing git repository of multiple projects

There is 1 main RoR project and 2 additional projects share some parts of main project - models, plugins, etc.

Currently all projects are under same svn repository with svn externals for shared parts.

What is best way of moving such layout to git?

like image 416
keymone Avatar asked Jan 06 '11 09:01

keymone


People also ask

Should I have multiple projects in one repository?

Yes you can, but is not recommended. Best practice is one repo per project always. Otherwise you have multiple projects updating one repo, that can mess with the code a fair bit if not set correctly. If the project is set up to be read-only on one project, that is an exception.

Is there a way to put multiple projects in a Git repository?

Yes. You can put multiple projects in one Git repository but they would need to be on different branches within that repo. The Git console in ReadyAPI gives you the ability to create or switch branches from the UI. More information on the Git integration can be found here in the documentation.


2 Answers

You will need a repository for each of the parts. (each project and one or more for the shared parts).

To include these shared parts there are two possibilities.

First the easy one, you create a (private) gem for the shared parts, that means you don't need to link anything, just add gem [gemname] to your Gemfile. When you update the gem, all projects will use the changed code.

When you want to include the external code in your project you need a little bit of organisation. You create a root map where you clone both the shared and project repository to. Then you create a (relative) symlink, to the shared code folder. You can just add this symlink to your git repository and commit it. You have to update and commit both repositories seperate.

An example of the second method:

- projectfolder
--- shared code
--- project code
----- lib
------- shared (link to shared code)

The link to shared code is created by the command ln -s "../../../shared code" shared

Ofcourse, this only works on systems supporting symbolic links (mac and *nix)

like image 79
Stefaan Colman Avatar answered Oct 05 '22 22:10

Stefaan Colman


Even though i accepted first answer we chose quite a different approach.

Since essentially all applications are just different aspects of 1 project(frontend, backend and api) they share A LOT therefore we decided to put them all into 1 repository and symlink shared parts(git can handle that).

This simplifies repository organization but slightly complicates deployment scripts which was ok tradeoff for us.

like image 44
keymone Avatar answered Oct 05 '22 22:10

keymone