DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Should You Switch to a Monorepo? A Developer’s No-Fluff Guide
  • CI/CD at Scale: Smarter Pipelines for Monorepo Mayhem
  • Monorepo Development With React, Node.js, and PostgreSQL With Prisma and ClickHouse
  • Guide To Setting up a Node.js Monorepo With Lerna

Trending

  • Mastering Fluent Bit: Beginners' Guide for Contributing to Our CNCF Project Website
  • Advanced Error Handling and Retry Patterns in Enterprise REST Integrations
  • Give Your AI Assistant Long-Term Memory With perag
  • Persistent Memory for AI Agents Using LangChain's Deep Agents
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Monorepos vs. Megarepos

Monorepos vs. Megarepos

Take a look at the differences and definitions of monorepos and megarepos, and which you should apply to your infrastructure.

By 
Paul Hammant user avatar
Paul Hammant
·
Jun. 14, 19 · Analysis
Likes (1)
Comment
Save
Tweet
Share
9.2K Views

Join the DZone community and get the full member experience.

Join For Free

Image title


I’ve been blogging about Google Monorepo for a number of years. Indeed, for a number of years before the practice of doing Trunk-Based Development in a single trunk/master branch for the whole dev org regardless of dev team became known as “Monorepos.”

What’s a Megarepo then? Well, it is the same idea but without the dev org doing a single from-root Trunk and all integrating there.

Consider a source tree:


app1/
  src/
    prod/
    test/
  BUILDFILE
app2/
  src/
    prod/
    test/
  BUILDFILE
svc3/
  src/
    prod/
    test/
  BUILDFILE
svc4/
  src/
    prod/
    test/
  BUILDFILE


In Git and Mercurial, you can only branch from the root. You have to run a command to see what branch you’re working on. You could run git status to tell you which branch you’re on. If you switched branches you’d not see that represented in the directory structure of the working copy, you’d have to run git status again to confirm. Maybe you’ve configured your shell/terminal to keep reminding you which branch you’re on. Of course, Trunk-Based Development teams, if they branch at all, are only making short-lived feature branches (PR branches), and delete them quickly once they’ve been merged/integrated into trunk/master.

In a true Trunk-Based Development + Monorepo model, Subversion, Perforce, or ClearCase teams may work this way (not quite so expanded):


branches/
  2019_04_Release/
    app1/
    app2/
    svc3/
    svc4/
  2019_05_Release/  
    app1/
    app2/
    svc3/
    svc4/
trunk/
  app1/
  app2/
  svc3/
  svc4/


With Subversion, Perforce, ClearCase, and others, though, you can branch anywhere. Yup, arbitrary branching is supported. Let’s look at the same source tree, but expanded a differently:


app1/
  trunk/
    src/
      prod/
      test/
    BUILDFILE
  branches/
    April_2019/
    May2019/
      src/
        prod/
        test/
      BUILDFILE
app2/
svc3/
svc4/
  branches/
    integ/
    orm_makeover/
    team4/
      src/
        prod/
        test/
      BUILDFILE


This dev organization isn’t doing Monorepo, they’re doing a single repo, with all buildable and shippable/deployable pieces in it (we presume), but each team is choosing where they do their branching and how. Many enterprises are like this, and know they probably should get to TBD, but not how. Let’s call that legacy corporate practice “mega repos” to differentiate it.

Companies that have only recently begun are doing multi-repos (popular with microservice teams) and one of a number of unapproved branching models*, or Monorepo with Trunk-Based Development. If they’re doing the latter they’re doing a recursive build style of modularity (Maven and alike for non-Java platforms), or a directed graph build system like Google’s Bazel or Facebook’s Buck. Pros and cons to both. Anyway, these new startups going monorepo have a natural advantage to legacy enterprises stuck in their megarepos and the associated practices.

Note: Big historical open source portals like the Apache Software Foundation keep all separate projects in a single megarepo, too (Subversion), at least historically. That was until Git’s popularity meant that the ASF deployed Git infrastructure, too, for a multi-repo setup and allowed projects to choose where they wanted to be and when to migrate. Each that ended up in Git was mirrored to GitHub as that is popular, too — still multi-repos, though.

Monorepo

Published at DZone with permission of Paul Hammant. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Should You Switch to a Monorepo? A Developer’s No-Fluff Guide
  • CI/CD at Scale: Smarter Pipelines for Monorepo Mayhem
  • Monorepo Development With React, Node.js, and PostgreSQL With Prisma and ClickHouse
  • Guide To Setting up a Node.js Monorepo With Lerna

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook