İçeriğe geç
wedevit

November 22, 2026 · 9 min read · software

İlhan Buğra Aslan

One change, three pull requests: monorepo or separate repositories?


A monorepo means keeping the code for several projects in a single version-controlled repository. It does not mean one application, one deployment artifact or one database; those are separate decisions that people routinely bundle into this one. And the choice is not a matter of taste. It is measurable: how often do your changes cross a project boundary? Go through the last three months of pull requests and count how many had to queue up behind "let's merge this one, cut a release, then do the other." A high number means your repository layout no longer matches how your team works. A low number means separate repositories are costing you nothing, and you have no reason to move.

In a multi-repo setup the bill arrives from predictable places. You fix two lines in a shared library, then version the package, publish it, bump the version in three consuming projects, open three pull requests and wait for three reviews. A few weeks later four services are running four different versions of that same library. A breaking change slips through to production because the consumer's tests still run against the old version. CI configuration spreads by copy-paste, one copy gets fixed and the other five do not. A new developer spends their first day working out which code lives where.

What a monorepo actually solves

The real prize is the atomic change. You modify an API and the client that calls it in the same commit, and the reviewer sees both the contract and its consequences in one diff. The question of which version works with which disappears, because the repository holds exactly one valid state. Being able to find every caller of a function with a single search makes paying down technical debt measurably cheaper. Patching a vulnerable dependency becomes one lockfile update, and on the supply chain side the question "which version of this package runs where" has a single answer. A shared component library is the classic case: when the design system lives in its own repository, changing the padding on a button turns into a three-day errand.

A monorepo is not a monolith

This is where most arguments go wrong. Folder layout is not architecture. Ten services in one repository can ship independently of each other, and ten services spread across ten repositories can still be locked into a single release because of the version coupling between them. Independent deployment is a property of your pipeline and your contracts, not of your directory tree. We covered the architectural side of that in monolith vs microservices.

Scale gets misread too. The Google paper in Communications of the ACM, on storing billions of lines in one repository, describes a repository that as of January 2015 held 86 TB of content, around 2 billion lines of code across 9 million source files, taking 40,000 commits per workday. The lesson is not that one repository works at any size. Google had to write its own version control system, Piper, precisely because off-the-shelf tools did not scale to that volume. A monorepo works for as long as you keep paying the tooling bill.

The first bill comes from CI

The day you move a second project into the same repository, every push starts building and testing everything. The fix is to compute which projects a change actually affects, using the dependency graph, and run only those. In the JavaScript and TypeScript world Nx and Turborepo give you this out of the box; for a polyglot codebase, Bazel and Pants trade a steeper learning curve for a more precise answer. Put a remote cache behind either one so the same input never gets built twice. Do not move that second project in before this is working, or the first thing to degrade will be feedback time, which is the metric at the centre of DORA's delivery measures.

There is one trap almost everyone walks into. If you restrict a GitHub Actions workflow with a paths filter, then on a pull request that does not match the filter the workflow never runs at all, its required check stays stuck in a Pending state, and the pull request cannot be merged. GitHub's own documentation spells this behaviour out and suggests a second workflow with the same check name that always reports success. It works, and it also hollows out the green tick: passing the check no longer means the tests passed. The sturdier approach is to let the workflow always trigger and push the filtering down to the job level, computing changed files there, so the check always runs and always reports something real.

When Git actually gets slow

People ask this early, and the answer is reassuring: most company codebases are nowhere near the threshold. A repository with fifty thousand files does not trouble Git. When it does start to, the tools are already there.

  • Partial clone. git clone --filter=blob:none skips file contents at clone time and fetches them on demand.
  • Sparse-checkout. Cone mode, introduced in Git 2.25, limits the working directory to the directories you care about. In GitHub's introduction to it, a repository with over a thousand folder patterns and roughly three million files saw pattern matching drop from five minutes to under a second.
  • Sparse index. The same team measured a repository of more than two million files with a cone covering about 100,000 of them: the index file went from over 180 MB to under 10 MB, and git status from 1.3 seconds to under 200 milliseconds.
  • File system monitor and Scalar. The built-in fsmonitor landed in Git 2.37, and Scalar, which turns on the large-repository settings as a bundle, became part of Git in 2.38.

None of this needs setting up in advance. Turn it on when git status starts being measured in seconds; until then the defaults are fine.

Access control: one repository, one door

On hosted Git platforms, read access is granted per repository, not per directory. The moment everything lives in one place, the contractor you brought in to look at a single module, and the intern who started on Monday, can technically read all of it. Three practical consequences follow.

First, keep genuinely restricted code out. A payments core, an integration written for one enterprise customer, a component you are contractually obliged to keep separate. If you have made commitments around source code ownership and escrow, the repository boundary is the only place you can actually enforce them.

Second, stop scoping CI credentials to the whole repository. A single deploy key now opens every project rather than one. Environment-scoped permissions, short-lived tokens and the rest of the discipline in handling secrets in source code matter more here, because the blast radius of one leaked key just grew.

Third, write ownership down. A CODEOWNERS file maps directories to teams, and combined with branch protection it pulls the right reviewer into the right pull request. Teams that skip it end up at one of two extremes: everyone reviews everything and the queue stretches out, or nobody owns any directory at all. The second quietly deepens the one person who knows the system problem.

Versioning: one state inside, contracts outside

A single repository removes most of the version-number bookkeeping for internal libraries. Consumers move in the same commit, so there is no compatibility matrix to maintain. Nothing changes for what you expose outward, though: public APIs and published packages still get versioned, and breaking changes still get announced. The rules in API versioning and backward compatibility are indifferent to how your folders are arranged. If you publish packages, add a tool that keeps a version and a changelog per project (Changesets is the best known of them), otherwise the setup drifts toward one global version number and packages that never changed get bumped on every release.

The middle path is usually the right one

This was never a binary choice. What works in practice is simple to state: things that change together live together, things on different release rhythms stay apart. If the web app and its backend change in the same sprint, put them in one repository. An integration service touched twice a year, infrastructure modules owned by another team, a component shipped under a different licence, all of those can keep their own. The dividing line is rhythm and ownership, not language or layer.

The criteria fit on one line each. How many of the last three months' pull requests touched more than one repository. How many copies of the same code are in circulation. How many repositories have to be coordinated to cut a release. Which directories someone must not have access to. How much CI budget you have. Answer those five and the decision makes itself.

Migrate one project at a time

You do not have to lose history. git subtree add --prefix=apps/web <url> main pulls a repository in as a subdirectory with its history intact, and when file paths need rewriting first, git-filter-repo moves them before the merge. Order matters: get affected-project detection and caching working first, move the second project after that. Do not delete the old repositories either. Archive them read-only and point the README at the new home, because open pull requests and stale links keep arriving for months.

The exit is open as well. git filter-repo --path extracts a directory with its history into a repository of its own. Of all the decisions a software team makes, repository layout is among the cheapest to reverse, nothing like a data model or an authentication choice. Which is why it deserves an experiment rather than a long meeting.

What you can do this week

One: scan the last three months of pull requests and count the ones that had to touch more than one repository, because that ratio settles the argument on its own. Two: list how many copies of shared code are circulating and how many versions of the same library are running in production. Three: set up affected-project detection and a remote cache in CI whichever layout you end up with, since the investment pays off in both. Four: open an empty pull request and check whether your required status checks get stuck behind a paths filter. Five: write a CODEOWNERS file and map directories to teams. Six: if you are consolidating, start by merging the two projects you change together most often and leave the third for next quarter.


Need help with this topic?

get in touch →← all posts