keymone
keymone

Reputation: 8094

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?

Upvotes: 6

Views: 945

Answers (2)

keymone
keymone

Reputation: 8094

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.

Upvotes: 2

Stefaan Colman
Stefaan Colman

Reputation: 3705

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)

Upvotes: 3

Related Questions