Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In a git environment, where we have modularized most projects, we're facing the one project per repository or multiple projects per repository design issue. Let's consider a modularized project:

   +-- gui
   +-- core
   +-- api
   +-- implA
   +-- implB

Today we're having one project per repository. It gives freedom to

  • release individual components
  • tag individual components

But it's also cumbersome to branch components as often branching api requires equivalent branches in core, and perhaps other components.

Given we want to release individual components can we still get the similar flexibility by utilizing a multiple projects per repository design.

What experiences are there and how/why did you address these issues?

share|improve this question
I have a very similar issue right now. I need to release different versions of a project so they will need to be in different repositories. This is a nightmare to manage though. It would be great if there was a way to branch just sub directories. –  Andrew Finnell Aug 18 '12 at 12:09
Each module need to have separate version numbers. And we use git-describe. –  linquize Sep 2 '13 at 9:26

3 Answers 3

up vote 63 down vote accepted

There are three major disadvantages to one project per repository, the way you've described it above. These are less true if they are truly distinct projects, but from the sounds of it changes to one often require changes to another, which can really exaggerate these problems:

  1. It's harder to discover when bugs were introduced. Tools like git bisect become much more difficult to use when you fracture your repository into sub-repositories. It's possible, it's just not as easy, meaning bug-hunting in times of crisis is that much harder.
  2. Tracking the entire history of a feature is much more difficult. History traversing commands like git log just don't output history as meaningfully with fractured repository structures. You can get some useful output with submodules or subtrees, or through other scriptable methods, but it's just not the same as typing tig --grep=<caseID> or git log --grep=<caseID> and scanning all the commits you care about. Your history becomes harder to understand, which makes it less useful when you really need it.
  3. New developers spend more time learning the VC structure before they can start coding. Every new job requires picking up procedures, but fracturing a project repository means they have to pick up the VC structure in addition the code's architecture. In my experience, this is particularly difficult for developers new to git who come from more traditional, centralized shops that use a single repository.

In the end, it's an opportunity cost calculation. At one former employer, we had our primary application divided into 35 different sub-repositories. On top of them we used a complicated set of scripts to search history, make sure state (i.e. production vs. development branches) was the same across them, and deploy them individually or en masse.

It was just too much; too much for us at least. The management overhead made our features less nimble, made deployments much harder, made teaching new devs take too much time, and by the end of it, we could barely recall why we fractured the repository in the first place. One beautiful spring day, I spent $10 for an afternoon of cluster compute time in EC2. I wove the repos back together with a couple dozen git filter-branch calls. We never looked back.

share|improve this answer
As an off topic aside, there are few more enjoyable things as a repository manager than purchasing time on a system that can do in two hours what your laptop couldn't do in 20, for less than the price of lunch. Sometimes I really love the internet. –  Christopher Aug 17 '12 at 15:47
How would you release those individual projects as separate releases? Or do you never need to do that? That is the problem I have. With if you need to create a V1 of Project A, and V2 of Project B. –  Andrew Finnell Aug 18 '12 at 12:16
For moving between the "one project per repo" and "multiple repos" consider git-subtree (good explanation at stackoverflow.com/a/17864475/15585) –  deterb Dec 6 '13 at 20:30

As we use GitHub, we actually have multiple projects in one repo but ensure that those projects/modules are properly modularised (we use -api and -core conventions + Maven + static and runtime checking and might even go to OSGi one day to boot).

What does it save on? Well we don't have to issue multiple Pull Requests if we're changing something small across multiple projects. Issues and Wiki are kept centralised etc.

We still treat each module/project as a proper independent project and build and integrate them separately in our CI server etc.

share|improve this answer
Very interesting. I'd suspect this is a common model on github. If you face individual component releases, do you employ something like submodules or release/tag the entire repository? –  Johan Sjöberg Aug 17 '12 at 14:09
submodules if we have to but for now we version from the parent down. –  Martijn Verburg Aug 17 '12 at 16:40
At my current employer we use a similar strategy, and package metadata about the most recent commit in a project into the various manifest files of artifacts (i.e. the results of git log -1 -- <project_dir>). It's really quite great. This answer deserves more upvotes. –  Christopher Feb 22 '14 at 4:30

For me, the main difference in using one or more than one repository are the answers to the following questions:

  • Are the multiple parts developed by the same team, have the same release cycle, the same customer? Then there are less reasons to split the one repository.
  • Are the multiple parts highly dependent on each other? So splitting model, controller and UI (even when they are different parts) is not very sensible, due to the high dependency on each other. But if 2 parts only have a small dependency, which is implemented by a stable interface that is only changed every few years, so it would be wise to divide the 2 parts in 2 repositories.

Just as an example, I have a small application (client only), that checks the "quality" of a Subversion repository. There is the core implementation, that could be started from the command line, and works well with Java 6. But I have started to implement a UI, that uses JavaFX as part of Java 8. So I have split the 2, and created a second repository (with a second build process), with different schedule, ...

I like the answers above (voted them up), but I think they are not the whole true story. So I wanted to add the arguments for splitting repositories as well. So the real answer (when to split) may be somewhere in the middle ...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.