1

Our server is setup to have multiple projects, which are worked on simultaneously by multiple users, located on the same server with each project sharing some source code. The setup is as follows:

  • /src/shared/ Code shared by multiple projects
  • /src/project_code/project1 code specific to project1
  • /src/project_code/project2 code specific to project2
  • etc.
  • /projects/project1 input and output for project1
  • /projects/project2 input and output for project2
  • etc.

We would like to have the source code (shared and project specific) under version control with git (but not the project data due to its size).

Our proposed solution to this is to have a single git repository for all source code (in /src). Then users would checkout the entire repository into the relevant project directory (e.g. /projects/project1) to work on the project (i.e. into /projects/project1/src). This is to avoid changes to any shared source code necessary for a project affecting other users working on other projects on the server. This single repository solution seems to make sense because the project specific code refers to the shared code and should therefore be tracked together. The plan would then be for bug fixes/improvements to be committed back to /src as necessary. At the end of project users can commit a specific version of all source code, so at a later date, this version can be checked out to replicate creation of all data for a specific project using the appropriate version of the project specific and shared source code.

The main disadvantage to this system is that each project directory will contain a copy of the shared source code, plus source code for every other project. However, since the source code is comparatively small, this is not a large overhead in terms of hard drive space

I would be very keen to hear any better solutions to this issue, before we commit to the above plan.

1 Answer 1

2

You want separate repos for the shared code and each project. Each project would have the shared code repo as a submodule.

Your tree would look something like:

  • /project1/src - Project 1's "local" source
  • /project1/lib/shared - Submodule of shared repo
  • /project2/src - Project 2's "local" source
  • /project2/lib/shared - Submodule of shared repo

See here for more info about submodules: http://git-scm.com/book/en/Git-Tools-Submodules

Sign up to request clarification or add additional context in comments.

2 Comments

Just to clarify, should the git repository for project1 should be located in /project1, and should have files in /project1/src added. Then /project1/lib/shared/ is a submodule cloned from /src/shared?
You can create the submodule as a standalone repository (e.g. /shared) and clone from that into each of your submodules. If one project "owns" the shared library more than the other, you can also create the repo inside as a submodule to begin with, and clone from it into the other project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.