DevOps help for Cloud Platform Engineers
  • Welcome!
  • Quick Start Guide
  • About Me
  • CV
  • 🧠DevOps & SRE Foundations
    • DevOps Overview
      • Engineering Fundamentals
      • Implementing DevOps Strategy
      • DevOps Readiness Assessment
      • Lifecycle Management
      • The 12 Factor App
      • Design for Self Healing
      • Incident Management Best Practices (2025)
    • SRE Fundamentals
      • Toil Reduction
      • System Simplicity
      • Real-world Scenarios
        • AWS VM Log Monitoring API
    • Agile Development
      • Team Agreements
        • Definition of Done
        • Definition of Ready
        • Team Manifesto
        • Working Agreement
    • Industry Scenarios
      • Finance and Banking
      • Public Sector (UK/EU)
      • Energy Sector Edge Computing
  • DevOps Practices
    • Platform Engineering
    • FinOps
    • Observability
      • Modern Practices
  • 🚀Modern DevOps Practices
    • Infrastructure Testing
    • Modern Development
    • Database DevOps
  • 🛠️Infrastructure as Code (IaC)
    • Terraform
      • Getting Started - Installation and initial setup [BEGINNER]
      • Cloud Integrations - Provider-specific implementations
        • Azure Scenarios
        • AWS Scenarios
        • GCP Scenarios
      • Testing and Validation - Ensuring infrastructure quality
        • Unit Testing
        • Integration Testing
        • End-to-End Testing
        • Terratest Guide
      • Best Practices - Production-ready implementation strategies
        • State Management
        • Security
        • Code Organization
        • Performance
      • Tools & Utilities - Enhancing the Terraform workflow
        • Terraform Docs
        • TFLint
        • Checkov
        • Terrascan
      • CI/CD Integration - Automating infrastructure deployment
        • GitHub Actions - GitHub-based automation workflows
        • Azure Pipelines - Azure DevOps integration
        • GitLab CI - GitLab-based deployment pipelines
    • Bicep
      • Getting Started - First steps with Bicep [BEGINNER]
      • Template Specs
      • Best Practices - Guidelines for effective Bicep implementations
      • Modules - Building reusable components [INTERMEDIATE]
      • Examples - Sample implementations for common scenarios
      • Advanced Features
      • CI/CD Integration - Automating Bicep deployments
        • GitHub Actions
        • Azure Pipelines
  • 💰Cost Management & FinOps
    • Cloud Cost Optimization
  • 🐳Containers & Orchestration
    • Containerization Overview
    • Docker
      • Dockerfile Best Practices
      • Docker Compose
    • Kubernetes
      • CLI Tools - Essential command-line utilities
        • Kubectl
        • Kubens
        • Kubectx
      • Core Concepts
      • Components
      • Best Practices
        • Pod Security
        • Security Monitoring
        • Resource Limits
      • Advanced Features - Beyond the basics [ADVANCED]
        • Service Mesh
        • Ingress Controllers
          • NGINX
          • Traefik
          • Kong
          • Gloo Edge
      • Troubleshooting - Diagnosing and resolving common issues
        • Pod Troubleshooting Commands
      • Enterprise Architecture
      • Health Management
      • Security & Compliance
      • Virtual Clusters
    • OpenShift
  • Service Mesh & Networking
    • Service Mesh Implementation
  • Architecture Patterns
    • Data Mesh
    • Multi-Cloud Networking
    • Disaster Recovery
    • Chaos Engineering
  • Edge Computing
    • Implementation Guide
    • Serverless Edge
    • IoT Edge Patterns
    • Real-Time Processing
    • Edge AI/ML
    • Security Hardening
    • Observability Patterns
    • Network Optimization
    • Storage Patterns
  • 🔄CI/CD & GitOps
    • CI/CD Overview
    • Continuous Integration
    • Continuous Delivery
      • Deployment Strategies
      • Secrets Management
      • Blue-Green Deployments
      • Deployment Metrics
      • Progressive Delivery
      • Release Management for DevOps/SRE (2025)
    • CI/CD Platforms - Tool selection and implementation
      • Azure DevOps
        • Pipelines
          • Stages
          • Jobs
          • Steps
          • Templates - Reusable pipeline components
          • Extends
          • Service Connections - External service authentication
          • Best Practices for 2025
          • Agents and Runners
          • Third-Party Integrations
          • Azure DevOps CLI
        • Boards & Work Items
      • GitHub Actions
      • GitLab
        • GitLab Runner
        • Real-life scenarios
        • Installation guides
        • Pros and Cons
        • Comparison with alternatives
    • GitOps
      • Modern GitOps Practices
      • GitOps Patterns for Multi-Cloud (2025)
      • Flux
        • Overview
        • Progressive Delivery
        • Use GitOps with Flux, GitHub and AKS
  • Source Control
    • Source Control Overview
    • Git Branching Strategies
    • Component Versioning
    • Kubernetes Manifest Versioning
    • GitLab
    • Creating a Fork
    • Naming Branches
    • Pull Requests
    • Integrating LLMs into Source Control Workflows
  • ☁️Cloud Platforms
    • Cloud Strategy
    • Azure
      • Best Practices
      • Landing Zones
      • Services
      • Monitoring
      • Administration Tools - Platform management interfaces
        • Azure PowerShell
        • Azure CLI
      • Tips & Tricks
    • AWS
      • Authentication
      • Best Practices
      • Tips & Tricks
    • Google Cloud
      • Services
    • Private Cloud
  • 🔐Security & Compliance
    • DevSecOps Overview
    • DevSecOps Pipeline Security
    • DevSecOps
      • Real-life Examples
      • Scanning & Protection - Automated security tooling
        • Dependency Scanning
        • Credential Scanning
        • Container Security Scanning
        • Static Code Analysis
          • Best Practices
          • Tool Integration Guide
          • Pipeline Configuration
      • CI/CD Security
      • Secrets Rotation
    • Supply Chain Security
      • SLSA Framework
      • Binary Authorization
      • Artifact Signing
    • Security Best Practices
      • Threat Modeling
      • Kubernetes Security
    • SecOps
    • Zero Trust Model
    • Cloud Compliance
      • ISO/IEC 27001:2022
      • ISO 22301:2019
      • PCI DSS
      • CSA STAR
    • Security Frameworks
    • SIEM and SOAR
  • Security Architecture
    • Zero Trust Implementation
      • Identity Management
      • Network Security
      • Access Control
  • 🔍Observability & Monitoring
    • Observability Fundamentals
    • Logging
    • Metrics
    • Tracing
    • Dashboards
    • SLOs and SLAs
    • Observability as Code
    • Pipeline Observability
  • 🧪Testing Strategies
    • Testing Overview
    • Modern Testing Approaches
    • End-to-End Testing
    • Unit Testing
    • Performance Testing
      • Load Testing
    • Fault Injection Testing
    • Integration Testing
    • Smoke Testing
  • 🤖AI Integration
    • AIops Overview
      • Workflow Automation
      • Predictive Analytics
      • Code Quality
  • 🧠AI & LLM Integration
    • Overview
    • Claude
      • Installation Guide
      • Project Guides
      • MCP Server Setup
      • LLM Comparison
    • Ollama
      • Installation Guide
      • Configuration
      • Models and Fine-tuning
      • DevOps Usage
      • Docker Setup
      • GPU Setup
      • Open WebUI
    • Copilot
      • Installation Guide
      • VS Code Integration
      • CLI Usage
    • Gemini
      • Installation Guides - Platform-specific setup
        • Linux Installation
        • WSL Installation
        • NixOS Installation
      • Gemini 2.5 Features
      • Roles and Agents
      • NotebookML Guide
      • Cloud Infrastructure Deployment
      • Summary
  • 💻Development Environment
    • Tools Overview
    • DevOps Tools
    • Operating Systems - Development platforms
      • NixOS
        • Installation
        • Nix Language Guide
        • DevEnv with Nix
        • Cloud Deployments
      • WSL2
        • Distributions
        • Terminal Setup
    • Editor Environments
    • CLI Tools
      • Azure CLI
      • PowerShell
      • Linux Commands
      • YAML Tools
  • 📚Programming Languages
    • Python
    • Go
    • JavaScript/TypeScript
    • Java
    • Rust
  • 📖Documentation Best Practices
    • Documentation Strategy
    • Project Documentation
    • Release Notes
    • Static Sites
    • Documentation Templates
    • Real-World Examples
  • 📋Reference Materials
    • Glossary
    • Tool Comparison
    • Recommended Reading
    • Troubleshooting Guide
  • Platform Engineering
    • Implementation Guide
  • FinOps
    • Implementation Guide
  • AIOps
    • LLMOps Guide
  • Development Setup
    • Development Setup
Powered by GitBook
On this page
  • Common Branching Strategies
  • 1. Trunk-Based Development
  • 2. GitFlow
  • 3. GitHub Flow
  • 4. Release Branch Model
  • Multi-Cloud Considerations
  • 1. Environment-Based Branching
  • 2. Provider-Specific Release Coordination
  • 3. Feature Branches with Provider Suffixes
  • Choosing the Right Strategy
  • Best Practices
  • 1. Branch Protection Rules
  • 2. Branch Naming Conventions
  • 3. Automated Testing on Branches
  • 4. Pull Request Templates
  • Migrating Between Strategies
  • From GitFlow to Trunk-Based Development
  • From GitHub Flow to Release Branches
  • Tools to Support Branching Strategies
  • Real-world Examples
  • Example 1: Trunk-Based Development with Feature Flags
  • Example 2: Environment Configuration for Multi-Cloud
  • Conclusion
Edit on GitHub
  1. Source Control

Git Branching Strategies

PreviousSource Control OverviewNextComponent Versioning

Last updated 4 hours ago

Effective branching strategies are essential for DevOps teams working in multi-cloud environments. This guide covers common branching models, their advantages and disadvantages, and best practices for implementation.

Common Branching Strategies

1. Trunk-Based Development

In trunk-based development, developers work primarily in the main branch ("trunk") or in short-lived feature branches that are merged frequently.

Trunk-Based Development

Benefits:

  • Reduces merge conflicts through frequent integration

  • Encourages continuous integration and small batches

  • Simplifies release automation

  • Less branching complexity

Challenges:

  • Requires strong automated testing

  • May be uncomfortable for teams new to CI/CD

  • Requires feature toggles for incomplete work

Best for:

  • High-velocity teams

  • Microservices architectures

  • Teams practicing continuous deployment

  • Cloud-native applications

Implementation:

# Create a short-lived feature branch
git checkout -b feature/api-optimization main

# Work locally, commit often
git commit -m "feat(api): optimize query performance"

# Stay up to date with main
git pull --rebase origin main

# Push branch and create PR
git push -u origin feature/api-optimization

# After review, merge to main
# Feature branch is deleted after merge

2. GitFlow

GitFlow is a more structured model with multiple long-lived branches including main, develop, feature branches, release branches, and hotfix branches.

Benefits:

  • Provides clear structure for larger teams

  • Supports multiple release versions in production

  • Clear separation between development and production code

Challenges:

  • Complex branching model

  • Can delay integration and feedback

  • Higher risk of merge conflicts

  • More difficult to automate

Best for:

  • Products with formal release cycles

  • Teams supporting multiple versions

  • Enterprise software with staged releases

Implementation:

# Initialize GitFlow
git flow init

# Start a feature
git flow feature start new-authentication

# Finish feature (merges to develop)
git flow feature finish new-authentication

# Start a release
git flow release start v1.2.0

# Finish release (merges to main and develop)
git flow release finish v1.2.0

3. GitHub Flow

GitHub Flow is a simplified workflow centered around the main branch and feature branches.

Benefits:

  • Simple and easy to learn

  • Good for continuous delivery environments

  • Clear process with pull requests

Challenges:

  • Less structure for complex projects

  • May not handle multiple release versions well

Best for:

  • Small to medium teams

  • Web applications with frequent deployments

  • Open source projects

Implementation:

# Create a branch for your feature/fix
git checkout -b feature-login-improvement

# Make changes, commit, and push
git commit -m "Implement OAuth login option"
git push -u origin feature-login-improvement

# Create pull request via GitHub UI
# After review and automated tests, merge to main
# Deploy from main

4. Release Branch Model

This model maintains a main development branch and creates release branches when preparing for a release.

Benefits:

  • Supports continued development during release stabilization

  • Enables bugfixes for specific releases

  • Clearer than GitFlow but more structured than trunk-based

Challenges:

  • Requires backporting fixes between branches

  • Can still lead to integration delays

Best for:

  • Teams transitioning from GitFlow to simpler models

  • Products with defined but frequent release cycles

Implementation:

# Work on main for daily development
git checkout main

# When preparing for release, create release branch
git checkout -b release/v1.5.0 main

# Fix bugs in release branch
git checkout release/v1.5.0
git commit -m "fix: address edge case in payment processing"

# Backport critical fixes to main
git checkout main
git cherry-pick <commit-hash>

Multi-Cloud Considerations

When working with infrastructure across multiple cloud providers:

1. Environment-Based Branching

For teams managing multi-cloud infrastructure:

main
├── environments/
│   ├── development/
│   │   ├── aws/
│   │   ├── azure/
│   │   └── gcp/
│   ├── staging/
│   └── production/

2. Provider-Specific Release Coordination

Use tags to mark tested configurations for specific providers:

# Tag Azure-specific release
git tag -a "azure/v1.2.0" -m "Release v1.2.0 for Azure environments"

# Tag AWS-specific release
git tag -a "aws/v1.2.0" -m "Release v1.2.0 for AWS environments"

3. Feature Branches with Provider Suffixes

For features specific to certain cloud providers:

# AWS-specific feature
git checkout -b feature/lambda-optimization-aws

# Azure-specific feature
git checkout -b feature/app-service-scaling-azure

Choosing the Right Strategy

Consider these factors when selecting a branching strategy:

  1. Team size and distribution

    • Larger teams may need more structure

    • Distributed teams benefit from clear workflows

  2. Deployment frequency

    • Continuous deployment favors simpler models

    • Scheduled releases work with more complex strategies

  3. Application architecture

    • Microservices fit well with trunk-based development

    • Monoliths may benefit from more controlled integration

  4. Product maturity

    • Established products may need to support multiple versions

    • New products can often use simpler strategies

  5. Automation capabilities

    • Strong CI/CD enables simpler branching models

    • Limited automation may require more structured approaches

Best Practices

1. Branch Protection Rules

Configure branch protection rules for important branches:

# Example GitHub branch protection configuration
branches:
  - name: main
    protection:
      required_pull_request_reviews:
        required_approving_review_count: 2
      required_status_checks:
        strict: true
        contexts: ["ci/build", "security-scan"]
      enforce_admins: true

2. Branch Naming Conventions

Establish clear branch naming conventions:

  • feature/<issue-id>-short-description - For new features

  • fix/<issue-id>-short-description - For bug fixes

  • hotfix/<issue-id>-short-description - For urgent production fixes

  • release/v1.2.3 - For release branches

  • docs/<short-description> - For documentation updates

3. Automated Testing on Branches

Enforce automated testing for all branches:

# GitHub Actions example
name: Branch Validation
on:
  push:
    branches-ignore:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '16'
      - run: npm ci
      - run: npm test

4. Pull Request Templates

Create standardized PR templates:

## Description
[Describe the changes you've made]

## Type of change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Infrastructure change

## Cloud providers affected
- [ ] AWS
- [ ] Azure
- [ ] GCP
- [ ] None/Other

## Testing performed
[Describe the testing you've done]

## Checklist
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review
- [ ] I have updated documentation
- [ ] I have added tests that prove my fix/feature works

Migrating Between Strategies

From GitFlow to Trunk-Based Development

  1. Start by reducing the lifetime of feature branches

  2. Implement feature flags for incomplete features

  3. Increase automated testing coverage

  4. Gradually move from develop to working directly with main

  5. Adopt CI/CD practices to support frequent integration

From GitHub Flow to Release Branches

  1. Keep working with feature branches and PRs to main

  2. Start creating release branches at specific milestones

  3. Implement processes for backporting fixes

  4. Add release versioning and tagging

Tools to Support Branching Strategies

  • Git Flow extensions: git-flow tools for implementing GitFlow

  • PR automation tools: GitHub Actions, Azure DevOps Pipelines

  • Feature flag services: LaunchDarkly, Flagsmith, or custom implementations

  • Branch analytics: GitHub Insights, GitPrime

  • Merge tools: Graphical merge tools like Beyond Compare or Meld

Real-world Examples

Example 1: Trunk-Based Development with Feature Flags

// Feature flag implementation example
function renderCheckout() {
  if (featureFlags.isEnabled('new-checkout-flow')) {
    return <NewCheckoutComponent />;
  } else {
    return <LegacyCheckoutComponent />;
  }
}

Example 2: Environment Configuration for Multi-Cloud

# Example GitHub Actions matrix strategy for multi-cloud testing
jobs:
  test-infrastructure:
    strategy:
      matrix:
        cloud: [aws, azure, gcp]
        include:
          - cloud: aws
            tf_dir: terraform/aws
          - cloud: azure
            tf_dir: terraform/azure
          - cloud: gcp
            tf_dir: terraform/gcp
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v2
      - name: Terraform Init
        run: terraform -chdir=${{ matrix.tf_dir }} init
      - name: Terraform Validate
        run: terraform -chdir=${{ matrix.tf_dir }} validate

Conclusion

Choose a branching strategy that matches your team's capabilities, project requirements, and release cadence. Simpler strategies like trunk-based development generally lead to faster delivery and fewer integration issues, but may require more mature DevOps practices. More complex strategies provide structure but can introduce delays and complexity.

The most important factor is team agreement and consistency - document your chosen approach and ensure everyone follows it.

GitFlow
GitHub Flow