TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Mono-Repo or Multi-Repo?

18 pointsby niros_valtosover 3 years ago
I know that there is a debate about storing all source code in a mono-repo vs multiple repos. I am thinking about it from a security perspective - a separation to multiple repos reduces the risk of source code exposure/leakage and enable more granular access. However, maybe this isn't a high risk as having an insider threat or an account takeover that may inject a malicious code, so setting up codeowners will do the work even in a mono-repo. What are your thoughts?

14 comments

aespinozaover 3 years ago
IMHO mono-repo vs multi-repo should be decided based on the sources of change for each component in a product. For example, the cloud components of a product usually change at the same pace and for the same reasons, it makes sense to have them in a mono-repo. Even in a microservices approach. Even in the cloud certain components can change at a different pace and for different reasons. For example if you have grpc api that talks to your mobile app and a webapi exposed to your customers.<p>I believe that components that move at a different pace and change for different reason should not be in the same repo. It is difficult to setup CI&#x2F;CD for different ways of deployment and specially if they not changing at the same time.<p>Now, regarding security, it is important to keep different components of a product in different repos, this will give you the flexibility to manage a more restricted set of credentials and reduce the number of people that have access to it.<p>In the end it involved 3 things: 1) Sources of Change, 2) CI&#x2F;CD Processes and 3) Security. You can definitely mix and match.
评论 #29653150 未加载
dupedover 3 years ago
To address the security concerns<p>- All code should require manual review from at least one other person (some orgs require 2+). It should be impossible to introduce a code change to any code base with a single compromised developer account. This is true of mono or multi repo<p>- The only really dangerous shit (like private keys, admin credentials) should not be accessible or committed to repos at all, ever.<p>- I&#x27;ve never worked anywhere where a source code leak was a legitimate threat (note: not that it wasn&#x27;t a concern, just that it doesn&#x27;t normally have drastic consequences, your code isn&#x27;t as special as you think)<p>- I have worked places with silo&#x27;d repos with granular access and I won&#x27;t do that again, I ask about it in technical interviews and if your company is doing this it&#x27;s not really a positive - making it harder for engineers to get work done for bad reasons is a sure fire way to get a toxic engineering culture. There&#x27;s plenty of places that give us engineers access to everything in the meanwhile.<p>So to me I don&#x27;t see the utility of multi repo from a security perspective - I&#x27;d argue the infrastructure problem it solves is the same as a package manager (having portions of systems moving at different rates without breaking dependent systems). If you have this problem in your code base then a multi repo org makes a lot of sense.
typedef_structover 3 years ago
If it releases&#x2F;deploys&#x2F;versions together, it shares a repo. Otherwise, meh.
Chyzwarover 3 years ago
Monorepo are usually better for security.<p><pre><code> - you can update dependencies of multiple components&#x2F;modules in one commit&#x2F;pr. In general, it would be easier to keep up with third party dependencies. - it is harder to monitor and audit multiple repositories than a single monorepo. An attacker can inject a malicious commit in one of the less active repositories and nobody will notice. </code></pre> In most cases, leakage is the same. If one developer PC get compromised, and you do not use 2FA, the attacker can still get access to most of the code. In many cases, data is a more interesting target than your source code.<p>From security perspective in order: 1. Educate your developers on security. 2. Develop threat model 3. Monitor for anomalies 4. Use 2FA auth 5. Secure your CI&#x2F;CD 6. Keep dependencies up to date 7. Security scanning
guenthertover 3 years ago
Security? What aspect of it? If your company is working on multiple projects for which different levels of security clearance are required, then there is little choice but to use multiple repositories.<p>Similar, if you work on projects for which the customers require following incompatible standardized (codified) procedures, then too multiple repositories are the obvious choice.<p>If the company you work for is in danger of being split up (for legal, commercial or other reasons) and different projects might go different paths, then you&#x27;d be happy to have chosen multiple repositories as well.<p>I&#x27;d think, one would have to have a <i>very</i> good reason to put multiple projects in a single repository.
gitgudover 3 years ago
Mono-repo is probably best, one repo is always easier to keep secure and track changes, rather than a group of repos...<p>I originally loved the elegance of the multi-repo approach, but in practice it&#x27;s just more of a pain...
softwaredougover 3 years ago
I like a monorepo because as a component evolves, it tests its assumptions against the current state of the other components. In a way it forces a dialog between the owners of those components to understand each other&#x27;s requirements.<p>It&#x27;s handy in cases where you tightly integrate and depend on each other&#x27;s code. Like a more <i>peer to peer</i> relationship. MOST of the time, working at a company, this has been my experience.<p>The other approach, multiple repos, I feel is best when there&#x27;s a one-to-many relationship. Like a service with many customers. Or an open source project...
gnurover 3 years ago
Duo repo seems to be the sweet spot for me.<p>1 for actual application code 1 for infra as code<p>First can automatically create a PR to the second when any component artefact changes. Also makes ci&#x2F;cd separation trivial
评论 #29654072 未加载
speedgooseover 3 years ago
A single repository for a project, but not for the whole company.<p>For example there is no need to have separate repositories for the front-end, the backend, the deployment, and a small microservices.<p>However, having the whole company using the same repository brings more downsides and problems in my humble opinion.
sirwhinesalotover 3 years ago
1 repo per project&#x2F;team. If you have more teams developing parts of a project, try to make them as independent as possible. Then each of those parts is effectively a separate project. This only applies if these parts are from separate, independent teams, otherwise monorepo.
voakbasdaover 3 years ago
Use a tool like ‘repo‘ to manage multiple repositories as a single unit. This gives the best of both worlds.<p><a href="https:&#x2F;&#x2F;gerrit.googlesource.com&#x2F;git-repo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gerrit.googlesource.com&#x2F;git-repo&#x2F;</a>
joejoesvkover 3 years ago
I&#x27;ll more worry about the security in the code...which is easier to do in mono...
factorialboyover 3 years ago
Mono. Thank me later.
joelbondurant0over 3 years ago
Monorepo of microservices including all infrastructure deployment.