In almost every large enterprise I've encountered, one consistent struggle persists: managing internal dependencies spread across numerous polyrepos. Often, the solution revolves around layering tooling and orchestration to tame complexity. But here's the issue: this only adds more complexity, more code to manage, and more opportunities for problems to compound.
Let's talk briefly about some traditional approaches:
A monorepo simplifies the developer experience significantly:
Yet, even with a monorepo, managing changes to and from external or internal dependencies remains challenging. You must still deal with synchronizing your changes with external repositories.
At TestifySec, when I joined as Director of Platform Engineering, we faced a daunting situation: polyrepos everywhere, unclear dependency boundaries, and a painful development cycle. With our seed funding on the horizon and a new engineering team incoming, it was imperative to streamline this immediately.
My solution? A monorepo powered by git subtrees.
Here's how I structured it:
/web
, /judge-api
, /infra
, /cd
/subtrees/*
.This provided clarity—anything under /subtrees/
was explicitly recognized as distributed code, deserving extra attention.
We identified three types of subtree management patterns:
To further streamline the workflow, we scripted the git subtree commands into makefiles. For example:
make subtrees-pull-<subtree-name>
make subtrees-push-<subtree-name>
This simplified even the more intricate operations of syncing changes upstream and downstream.
Git subtrees aren't without quirks:
Despite these challenges, the subtree model significantly enhanced our workflow.
Implementing git subtrees within a monorepo radically improved our developer experience, accelerated feature development, simplified onboarding, and shortened the time to value. Our entire CI/CD infrastructure became simpler, and our ability to rapidly deliver high-value features dramatically increased.
This architecture was crucial when we faced aggressive deadlines, such as launching a public SaaS and achieving an AWS marketplace listing simultaneously within a 4-week sprint. Without our monorepo powered by git subtrees, these ambitious targets might have been unattainable.
Git subtrees, combined with a carefully organized monorepo, offer an elegant, scalable solution to managing distributed code. If your organization struggles with the complexity of polyrepos and dependency management, consider giving git subtrees a try—you might just regain your sanity.