Answers: <p>Git works for monorepos, but it has a few problems:</p>
  
  <ol>
  <li>You have to check out the entire repo.</li>
  <li>You have to fetch the entire history (generally - shallow clones are an option, but usually not useful in actual development work).</li>
  <li>Natively, everyone has read+write access to every directory if they have it at all.</li>
  </ol>
  
  <p>Google, probably the most famous monorepo user, developed <a href="https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext" rel="noreferrer">Piper</a> to handle their needs.  But you aren't Google, and so their solutions are probably not yours.</p>
  
  <p>One of the key advantages to a monorepo is that you can make globally-atomic changes (i.e. you don't need to version many things because you can change the caller and the callee in the same commit).  To power this, you really want to have a unified build system that tracks dependencies across the entire repo.  <a href="https://bazel.build/" rel="noreferrer">Bazel</a> is an open-source extraction of Google's build system, Blaze, and it attempts to do that (although it's young and immature and missing a lot of features that are necessary for non-Google use).  <a href="https://www.pantsbuild.org/" rel="noreferrer">Pants</a> is a similar system out of Twitter.</p>
  
  <p>If you're building tons of code when you make such an atomic change, then you probably also want a build farm that allows you to do that not on your local machine.  Similarly, you'll need a powerful CI system to handle running tests across everything as you update.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-05T17:23:21.737Z
Answers: 2018-05-05T17:23:21.737Z
Answers: Xiong Chiamiov
Answers: <p>The answer is: a bit of both. To satisfy the constraints of "use git" and "manage a vast codebase" Microsoft <a href="https://blogs.msdn.microsoft.com/devops/2017/02/03/announcing-gvfs-git-virtual-file-system/" rel="noreferrer">developed a new filesystem</a> (previously they were using a variant of Perforce called SourceDepot). It's <a href="https://github.com/Microsoft/gvfs" rel="noreferrer">open source</a> but I have no personal experience of using it. </p>
  
  <p>Why would you want a monorepo? The most obvious reason is that you can modify an API and all the callers of that API in an atomic commit. Also there are advantages to being able to do a <code>git log</code> search across the entire codebase...</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-04T07:46:08.773Z
Answers: 2018-05-04T07:46:08.773Z
Answers: Gaius
Answers: <p>Opinions differ on what a large code base is. If you are speaking about a company with 100 engineers, I would argue that Git should still be able to handle it. It has been developed for the needs of the Linux kernel, which is not a small project on its own.</p>
  
  <p>Independent of the way how you store the repository, you may run into problems. For instance, if you are working on a large Java code base and are using tools like Eclipse or IntelliJ, they will use more memory and generally become slower.</p>
  
  <p>On the other hand, having the option to operate on all code at once (e.g., when applying refactoring, or source code transformations) is one of the main advantages of monolithic repositories.</p>
  
  <p>When you ask about whether you need specialized tools, then up a certain code size, the answer is yes. According to Google, which arguably has the biggest C++ codebase in the world, all available tools (open source or commercial) did not satisfy their requirements. They ended up developing an inhouse system called Piper:</p>
  
  <ul>
  <li><a href="https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext" rel="nofollow noreferrer">Why Google Stores Billions of Lines of Code in a Single Repository</a></li>
  <li><a href="https://www.quora.com/What-version-control-system-does-Google-use-and-why" rel="nofollow noreferrer">What version control system does Google use and why?</a></li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-08T12:31:20.580Z
Answers: 2018-05-08T12:31:20.580Z
Answers: Philipp Claßen
Answers: <p>If I understand it correctly the "need" for a monorepo is simply the fundamental need of a single/coherent versioning scheme applied to a software project containing multiple loosely-related components/sub-projects which are/could be otherwise managed/versioned independently in separate repositories.</p>
  
  <p>Similar, if you want, with the need of using a regular source repository to provide a single/coherent versioning scheme for a multitude of source files, each with their own, independent modification history.</p>
  
  <p>Using an actual monorepo solution is definitely one, but IMHO not the only way of addressing this need.</p>
  
  <p>Another possible approach is using an umbrella project repository containing one or more manifest files with the exact version of each of the individual project component repositories. </p>
  
  <p>Even if the component repositories have their versions modified by independent, non-atomic commits, the project itself can be managed coherently simply by combining all related component repository version changes into a single commit to the manifest file(s) in the umbrella repository.</p>
  
  <p>Such approach has several advantages over migrating to an actual monorepo solution:</p>
  
  <ul>
  <li>no need to change the existing component repositories</li>
  <li>can support mixes of components with different repository technologies</li>
  <li>each component repository can still be developed and managed independently</li>
  <li>adding/deleting project components is almost trivial</li>
  <li>integrating 3rd party (upstream) components is a whole lot easier</li>
  <li>the project history can be kept much cleaner, not polluted with all the details of each individual component repository change (which typically would be irrelevant for the other components)</li>
  <li>no need to worry about size/performance/scalability of a single repository, the solution itself is highly scalable.</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2018-05-04T14:50:23.817Z
Answers: 2018-05-04T14:50:23.817Z
Answers: Dan Cornilescu
Body: <p>From certain size of the codebase, would you still have Git or are there more specialized solutions? </p>
  
  <p>(Also to checkout just a part of the codebase)</p>
  
Tags: <git><monorepo>
Title: What do you need for a monorepo for a large codebase?
UserDisplayName: Ta Mu
ThreadText: # What do you need for a monorepo for a large codebase?
  
  (Asked by: username_0 on 2018-05-04)
  
  From certain size of the codebase, would you still have Git or are there more specialized solutions?
  
  (Also to checkout just a part of the codebase)
  
  **Tags:** git, monorepo
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2018-05-05. Score: 4
  
  Git works for monorepos, but it has a few problems:
  
  1. You have to check out the entire repo.
  2. You have to fetch the entire history (generally - shallow clones are an option, but usually not useful in actual development work).
  3. Natively, everyone has read+write access to every directory if they have it at all.
  
  Google, probably the most famous monorepo user, developed [Piper](https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext) to handle their needs. But you aren't Google, and so their solutions are probably not yours.
  
  One of the key advantages to a monorepo is that you can make globally-atomic changes (i.e. you don't need to version many things because you can change the caller and the callee in the same commit). To power this, you really want to have a unified build system that tracks dependencies across the entire repo. [Bazel](https://bazel.build/) is an open-source extraction of Google's build system, Blaze, and it attempts to do that (although it's young and immature and missing a lot of features that are necessary for non-Google use). [Pants](https://www.pantsbuild.org/) is a similar system out of Twitter.
  
  If you're building tons of code when you make such an atomic change, then you probably also want a build farm that allows you to do that not on your local machine. Similarly, you'll need a powerful CI system to handle running tests across everything as you update.
  
  
  ---
  
  ### Answer by username_2 on 2018-05-04. Score: 4
  
  The answer is: a bit of both. To satisfy the constraints of "use git" and "manage a vast codebase" Microsoft [developed a new filesystem](https://blogs.msdn.microsoft.com/devops/2017/02/03/announcing-gvfs-git-virtual-file-system/) (previously they were using a variant of Perforce called SourceDepot). It's [open source](https://github.com/Microsoft/gvfs) but I have no personal experience of using it.
  
  Why would you want a monorepo? The most obvious reason is that you can modify an API and all the callers of that API in an atomic commit. Also there are advantages to being able to do a `git log` search across the entire codebase...
  
  
  ---
  
  ### Answer by username_3 on 2018-05-08. Score: 1
  
  Opinions differ on what a large code base is. If you are speaking about a company with 100 engineers, I would argue that Git should still be able to handle it. It has been developed for the needs of the Linux kernel, which is not a small project on its own.
  
  Independent of the way how you store the repository, you may run into problems. For instance, if you are working on a large Java code base and are using tools like Eclipse or IntelliJ, they will use more memory and generally become slower.
  
  On the other hand, having the option to operate on all code at once (e.g., when applying refactoring, or source code transformations) is one of the main advantages of monolithic repositories.
  
  When you ask about whether you need specialized tools, then up a certain code size, the answer is yes. According to Google, which arguably has the biggest C++ codebase in the world, all available tools (open source or commercial) did not satisfy their requirements. They ended up developing an inhouse system called Piper:
  
  * [Why Google Stores Billions of Lines of Code in a Single Repository](https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext)
  * [What version control system does Google use and why?](https://www.quora.com/What-version-control-system-does-Google-use-and-why)
  
  
  ---
  
  ### Answer by username_4 on 2018-05-04. Score: 0
  
  If I understand it correctly the "need" for a monorepo is simply the fundamental need of a single/coherent versioning scheme applied to a software project containing multiple loosely-related components/sub-projects which are/could be otherwise managed/versioned independently in separate repositories.
  
  Similar, if you want, with the need of using a regular source repository to provide a single/coherent versioning scheme for a multitude of source files, each with their own, independent modification history.
  
  Using an actual monorepo solution is definitely one, but IMHO not the only way of addressing this need.
  
  Another possible approach is using an umbrella project repository containing one or more manifest files with the exact version of each of the individual project component repositories.
  
  Even if the component repositories have their versions modified by independent, non-atomic commits, the project itself can be managed coherently simply by combining all related component repository version changes into a single commit to the manifest file(s) in the umbrella repository.
  
  Such approach has several advantages over migrating to an actual monorepo solution:
  
  * no need to change the existing component repositories
  * can support mixes of components with different repository technologies
  * each component repository can still be developed and managed independently
  * adding/deleting project components is almost trivial
  * integrating 3rd party (upstream) components is a whole lot easier
  * the project history can be kept much cleaner, not polluted with all the details of each individual component repository change (which typically would be irrelevant for the other components)
  * no need to worry about size/performance/scalability of a single repository, the solution itself is highly scalable.
  
  
  ---
  
  