Course contentsShow
← Cloud and Infrastructure
Lesson 1861 of 2,98939. GitOps PrinciplesFree lesson

GitOps Repository Structures

Monorepo vs polyrepo patterns and how to organize application and infrastructure repositories.

GitOps Repository Structures

You'll learn: How to organize your Git repositories for GitOps workflows—choosing between monorepo and polyrepo patterns to manage applications and infrastructure.

The Central Question

When adopting GitOps, one of your first decisions is: should you keep everything in one giant repository (monorepo) or split things across multiple repositories (polyrepo)? This choice affects collaboration, deployment velocity, and operational complexity.

Monorepo Pattern

A monorepo houses all your application code, infrastructure definitions, and configurations in a single repository. Think of it like keeping all your household documents in one filing cabinet—everything's in one place.

Advantages:

  • Atomic changes across apps and infrastructure
  • Simplified dependency management
  • Single source of truth location
  • Easier to enforce organization-wide standards

Trade-offs:

  • Can grow large and unwieldy
  • Requires more sophisticated access controls
  • One repository failure affects everyone

Polyrepo Pattern

A polyrepo approach splits concerns into separate repositories—perhaps one per application, one for shared infrastructure, and another for environment configs. Like having separate filing cabinets for different departments.

Advantages:

  • Clear ownership boundaries
  • Independent deployment lifecycles
  • Granular access control
  • Smaller, faster repositories

Trade-offs:

  • Cross-repo changes require coordination
  • Managing multiple repositories overhead
  • Duplicate configurations possible

Typical Organization

Most teams use hybrid patterns: application code in app-specific repos, shared infrastructure (Kubernetes manifests, Terraform) in a platform repo, and environment-specific configs in separate repos per environment (dev/staging/prod).

Key Takeaway: Choose monorepo for tightly coupled systems and small teams; use polyrepo for clear service boundaries and independent release cycles. Many successful GitOps implementations use a hybrid approach balancing both patterns.