Occlude
Book a call

Occlude vs splitting the repository or using submodules

Splitting the repository is the free, standard way to keep code from a contractor. Where submodules, subtrees and sparse checkout work, and where they break.

Splitting the repository is the standard way to keep part of a codebase from a contractor, and when the code divides cleanly it is the right one: it is free and needs no vendor. Occlude is for the case where it does not divide cleanly, because the two sides share types and change together.

Two panels. Split into two repositories, the app imports billing across a broken line and builds against a stand-in. In one repository in Occlude, billing is a solid bar for the contractor but the import reaches the real code and the build uses itTwo panels. Split into two repositories, the app imports billing across a broken line and builds against a stand-in. In one repository in Occlude, billing is a solid bar for the contractor but the import reaches the real code and the build uses it
Splitting moves the line into the build. Occlude keeps one repository and moves the line into what the person can see.

This page goes through the four ways teams split, what each costs, and how to tell which case you are in.

The four ways to split

MethodWhat the contractor getsWhat you maintain
A second repositoryA repository holding only their partA sync in both directions, and an interface between the two
SubmodulesThe outer repository, without access to the inner oneTwo commit histories that must be moved in step
SubtreeA separate remote for one folderSplits and merges for that folder
Sparse checkoutThe whole repository, with most of it not checked outNothing. It is not access control

A second repository

The oldest answer. Copy the contractor's part to its own repository, give them that, and carry changes across. On Stack Overflow, an experienced Git answerer described what he usually sees for contractors on a monorepo:

"I usually see an intermediate gate repository, composed of the relevant parts for the contractor to work, with a synchronization process to import/export to work."

The work is in that last clause. Someone on your team owns the synchronization, and anything the contractor's code calls on the other side has to be published to them as a package or replaced by a stand-in.

Submodules

A submodule keeps a second repository inside the first. Git's own book introduces the idea this way: "you want to be able to treat the two projects as separate yet still be able to use one from within the other."

For access, that means you can leave a contractor without rights to the inner repository. For daily work, it means two histories. A developer on Hacker News described the routine: "When working on both, it's really annoying to have to commit to a dependency's repo, push, and pull down in the dependent repo."

Subtree

A subtree publishes one folder of a repository as a repository of its own. The accepted answer to the monorepo and contractor question on Stack Overflow recommends it: "the contractor would be given access to only the remote repo tied to a single subtree of the monorepo."

It is the tidiest of the three, and it has the same limit. A comment under the same question, from one of the site's best-known Git experts, names it: the subtree approach is "useless unless there's a well-defined subtree."

Sparse checkout

Sparse checkout is often suggested and does not belong on the list. Git's manual describes it as a way to "Reduce your working tree to a subset of tracked files". It makes a large repository lighter to work in. The person still has read access to everything.

It is useful here for one reason: it shows what happens to a build when files are missing. An open issue on Bazel describes it. In a sparse checkout, "source files are not present in the worktree", and a user "has to maintain two independent sources of truth for which files are needed in a build."

Where splitting breaks

All three real methods depend on the same thing: a line through the codebase that few changes cross.

When the line is clean, a mobile app and the service it calls over a documented interface, splitting costs little and you should do it.

When it is not, three things follow.

  • The contractor cannot build the real thing. Their code imports types and modules from the side they cannot have, so they build against a stand-in.
  • The stand-in drifts. Every change to the protected side has to be reflected in what the contractor builds against, by hand or by a pipeline someone maintains.
  • Every crossing change costs twice. One feature becomes two changes in two places, reviewed and merged in order.

This is an old problem. On the Subversion developers' list, years before Git existed, a manager described contractors kept out of part of the source and unable to compile their changes before checking them in. The reply to the question of whether that was really the case was "Believe it or not that was the case."

How Occlude differs

Occlude does not move code between repositories. The repository stays whole. The contractor works in a workspace in your cloud and sees the files their task needs. The compiler, the tests and the dev server see every file.

Splitting the repositoryOcclude
Repository layoutChanged to match who may see whatUnchanged
The contractor's buildAgainst stand-ins or published packagesAgainst the real code
A change that crosses the lineTwo changes, kept in stepOne change
Changing who may see whatMove code between repositoriesEdit a profile
Where the code isOn the contractor's laptop, for their partIn your cloud
CostEngineering time, no licenceA product to run
MaturityDecadesNew

Which to choose

Split the repository if you can draw the line and most changes stay on one side of it. It is cheaper than Occlude and always will be.

Look at Occlude, which gives outsiders partial repository access by code masking, if you have tried to draw that line and found shared types on both sides, or if you are already paying someone to keep two repositories in step.

Sources

Each quotation was read on its source page on 28 November 2026. Forum, comment and mailing-list quotations are the views of their authors.

Want to go through this for your codebase?

All posts