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

Branching Strategies for GitOps

Implement branching models (trunk-based, environment branches) that align with GitOps promotion workflows.

Branching Strategies for GitOps

What You'll Learn

You'll learn how to structure Git branches to support controlled, staged promotion of infrastructure changes through environments in a GitOps workflow.

Why Branching Matters in GitOps

Since Git is the single source of truth in GitOps, your branching model directly determines how changes flow from development to production. Unlike traditional CI/CD where branches mainly organize code, GitOps branches represent actual environment states that your cluster continuously reconciles against.

Two Common Branching Models

Trunk-Based Development

In this model, you maintain a single main branch as the source of truth for production. Changes merge quickly through short-lived feature branches, and environment differentiation happens through:

  • Overlays or kustomizations (different manifests per environment)
  • Path-based separation (/envs/dev, /envs/prod)
  • Repository separation (one repo per environment)

This approach minimizes merge conflicts and keeps deployment simple but requires discipline around testing before merge.

Environment Branches

Here you maintain long-lived branches like dev, staging, and production. Changes flow sequentially:

  1. Commit to dev branch → dev cluster reconciles
  2. Merge dev → staging → staging cluster reconciles
  3. Merge staging → production → production deploys

This creates clear promotion gates and matches how many teams mentally model environments, but introduces merge overhead and potential drift between branches.

Choosing Your Strategy

Trunk-based suits teams with strong automation and testing, prioritizing velocity. Environment branches work better when you need explicit promotion gates, manual approvals, or regulatory separation between environments.

Key Takeaway: Your GitOps branching strategy defines your deployment promotion path—trunk-based with overlays favors speed, while environment branches provide explicit gates and audit trails for staged releases.