Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Branching Strategy Master Tutorial

From Beginner to Advanced: A Complete One-Stop Guide to Choosing, Designing, and Governing Branches


1. What is a branching strategy?

A branching strategy is a teamโ€™s rulebook for how branches are created, used, reviewed, merged, released, protected, and deleted.

It answers:

  • Which branch is production?
  • Which branch do developers start from?
  • How long can a branch live?
  • When do we create feature branches?
  • When do we create release branches?
  • When do we create hotfix branches?
  • Do we use main, develop, release/*, hotfix/*, or only trunk?
  • How do changes move from development to production?
  • How do we avoid merge hell?
  • How do we support old versions?
  • How do we roll back safely?
  • How do CI/CD, code review, and branch protection fit?

Simple definition:

A branching strategy is the traffic control system for software changes.

A weak strategy creates chaos.
A good strategy creates flow.
A great strategy lets teams move fast without making production fragile.


2. Branching strategy vs Git workflow vs software delivery workflow

These are related, but not the same.

TermMeaningExample
Branching strategyHow branches are structured and mergedGitflow, trunk-based, GitHub Flow
Git workflowHow developers use Git day to daybranch โ†’ commit โ†’ PR โ†’ merge
Version control workflowComplete source-control processcommits, branches, tags, reviews
Software delivery workflowFull path from idea to productionplan โ†’ code โ†’ test โ†’ deploy โ†’ observe
Release strategyHow versions are shippedtags, release branches, canary, blue-green

Branching strategy is one layer inside the wider delivery system.

flowchart TD
    A[Software Delivery Workflow] --> B[Version Control Workflow]
    B --> C[Git Workflow]
    C --> D[Branching Strategy]
    D --> E[Branch Names, Merge Rules, Release Rules, Hotfix Rules]
Code language: CSS (css)

3. Why branching strategy matters

Bad branching causes:

  • long merge conflicts
  • broken main
  • unclear production state
  • duplicated work
  • unstable release branches
  • forgotten hotfixes
  • huge pull requests
  • slow delivery
  • risky production releases
  • environment drift
  • unclear rollback

Good branching creates:

  • safe collaboration
  • faster review
  • predictable releases
  • cleaner history
  • lower production risk
  • easier hotfixes
  • better CI/CD
  • better audit trail
  • simpler rollback
  • happier engineers

The official Git book describes branching and merging as normal daily operations, including creating a branch for work, switching to a hotfix, and merging completed work back.


4. The most important mental model

A branch is not a place to hide work forever.

A branch is a temporary safety boundary.

Branch = temporary isolation for a clear purpose

Every branch must answer:

Why does this branch exist?
What risk does it isolate?
When will it be merged or deleted?
Who owns it?
Code language: JavaScript (javascript)

If nobody can answer those questions, the branch is probably technical garbage slowly fossilizing in your repository. Tiny archaeology site. Bad vibes.


5. The five reasons branches exist

Most branches exist for one of five reasons.

PurposeBranch typeExample
New workFeature branchfeature/add-login
Normal bug fixBugfix branchbugfix/payment-timeout
Production emergencyHotfix branchhotfix/prod-crash
Release stabilizationRelease branchrelease/2.4.0
Old version supportSupport branchsupport/1.9-lts

If a branch does not support development, review, release, hotfix, or support, question it.


6. Core branch types

6.1 main / master / trunk

This is the primary integration branch.

Modern repositories usually use:

main

Older repositories may still use:

master

Trunk-based teams may call it:

trunk

In trunk-based development, teams collaborate around a single branch called trunk, main, or mainline, avoiding long-running development branches.


6.2 Feature branch

Used for new work.

feature/add-user-login
feature/device-search
feature/report-export
Code language: JavaScript (javascript)

Feature branches should be short-lived. The trunk-based development reference describes short-lived feature branches as branches intended to come back as pull requests into trunk/main.


6.3 Bugfix branch

Used for non-emergency defects.

bugfix/login-timeout
bugfix/wrong-invoice-total
bugfix/api-null-response
Code language: JavaScript (javascript)

6.4 Hotfix branch

Used for urgent production repair.

hotfix/payment-crash
hotfix/security-token-leak
hotfix/prod-login-failure

Hotfix branches must be small, focused, quickly reviewed, and merged back into every active branch that needs the fix.


6.5 Release branch

Used to stabilize a version before shipping.

release/1.5.0
release/2026.07
release/mobile-4.2.0

Release branches are useful when QA, certification, app-store approval, enterprise release windows, or version support require a controlled stabilization line.


6.6 Support / LTS branch

Used to maintain old versions.

support/1.9-lts
support/2.x
maintenance/2025-lts

These branches exist when customers or systems cannot immediately upgrade to the newest version.


6.7 Environment branch

Used when branches map directly to environments.

dev
staging
production

GitLabโ€™s documentation lists branch-per-environment as one possible branching strategy, alongside web-service and long-lived release-branch approaches.

Environment branches can work, but they can also drift badly if teams make direct changes in different branches.


7. The lifecycle of a healthy branch

flowchart TD
    A[Create from correct base] --> B[Make small commits]
    B --> C[Push branch]
    C --> D[Open PR/MR]
    D --> E[CI checks]
    D --> F[Code review]
    E --> G{Checks pass?}
    F --> H{Approved?}
    G -- No --> B
    H -- No --> B
    G -- Yes --> I[Merge]
    H -- Yes --> I
    I --> J[Delete branch]
Code language: JavaScript (javascript)

Healthy branches are:

  • clearly named
  • short-lived
  • owned
  • reviewed
  • tested
  • merged
  • deleted

Unhealthy branches are:

  • old
  • unclear
  • huge
  • unreviewed
  • never merged
  • never deleted
  • impossible to rebase
  • terrifying to touch

8. Branch lifetime guide

Branch typeIdeal lifetimeMaximum recommended lifetime
feature/*Hours to 3 days1 week
bugfix/*Hours to 2 days1 week
hotfix/*Minutes to hours1 day
release/*Days to weeksRelease-dependent
support/*Months to yearsProduct-dependent
experiment/*Hours to days1โ€“2 weeks
Environment branchLong-livedMust be strictly governed
xychart-beta
    title "Branch age vs merge risk"
    x-axis ["Hours", "1 day", "3 days", "1 week", "2 weeks", "1 month"]
    y-axis "Integration risk" 0 --> 100
    bar [5, 10, 25, 45, 75, 95]
Code language: JavaScript (javascript)

The chart is conceptual, but the lesson is painfully real:

Long-lived branches do not remove integration pain.
They delay it and make it bigger.
Code language: JavaScript (javascript)

9. The major branching strategies

The major strategies are:

  1. Mainline strategy
  2. Feature branch strategy
  3. GitHub Flow
  4. GitLab Flow
  5. Gitflow
  6. Trunk-based development
  7. Release branch strategy
  8. Environment branch strategy
  9. Fork-based strategy
  10. GitOps branching strategy
  11. Monorepo branching strategy
  12. Support/LTS strategy
mindmap
  root((Branching Strategies))
    Mainline
    Feature Branch
    GitHub Flow
    GitLab Flow
    Gitflow
    Trunk Based Development
    Release Branch
    Environment Branch
    Fork Based
    GitOps
    Monorepo
    Support LTS

10. Strategy 1: Mainline strategy

What it is

Everyone works close to one main branch.

main
gitGraph
    commit id: "A"
    commit id: "B"
    commit id: "C"
    commit id: "D"
Code language: JavaScript (javascript)

Best for

  • solo developers
  • prototypes
  • small internal tools
  • learning repositories
  • scripts
  • tiny teams with strong discipline

Pros

BenefitExplanation
SimpleFew branches
FastNo complex promotion
Easy to understandGood for beginners

Cons

RiskExplanation
Easy to break mainIf no reviews/checks
Weak governanceNo release structure
Risky for large teamsToo much direct integration

Recommended rules

main must always build
commit small
pull before push
use CI
tag important versions
avoid direct production deployment from laptops
Code language: JavaScript (javascript)

Verdict

Mainline is fine for small/simple work. For professional teams, add PRs, CI, and branch protection quickly.


11. Strategy 2: Feature branch strategy

What it is

Each task gets its own temporary branch.

main
feature/*
bugfix/*
hotfix/*
gitGraph
    commit id: "main-1"
    branch feature/login
    checkout feature/login
    commit id: "login-1"
    commit id: "login-2"
    checkout main
    merge feature/login
    branch bugfix/payment
    checkout bugfix/payment
    commit id: "fix-payment"
    checkout main
    merge bugfix/payment
Code language: JavaScript (javascript)

Workflow

flowchart LR
    A[main] --> B[feature branch]
    B --> C[PR/MR]
    C --> D[CI + review]
    D --> E[merge to main]
    E --> F[delete branch]
Code language: CSS (css)

Best for

  • most engineering teams
  • backend services
  • frontend apps
  • Terraform repositories
  • Kubernetes manifests
  • documentation
  • teams not ready for full trunk-based development

Pros

BenefitExplanation
Clear isolationWork does not immediately affect main
PR-friendlyNatural review workflow
Beginner-friendlyEasy to understand
Works with CI/CDGood default

Cons

RiskExplanation
Branches can live too longCreates merge conflicts
Huge PRsReview quality drops
Delayed feedbackProblems appear late

Best practice

Keep feature branches short-lived and PRs small.

12. Strategy 3: GitHub Flow

What it is

GitHub Flow is a lightweight branch-based workflow. GitHubโ€™s official documentation describes it as: create a branch, make changes, create a pull request, address review comments, merge, and delete the branch.

flowchart LR
    A[Create branch] --> B[Make commits]
    B --> C[Open pull request]
    C --> D[Review and discuss]
    D --> E[CI checks]
    E --> F[Merge to main]
    F --> G[Deploy]
Code language: CSS (css)

Branches

main
feature/*
bugfix/*
hotfix/*

Philosophy

main is always deployable.

Best for

  • web applications
  • SaaS products
  • APIs
  • documentation sites
  • internal tools
  • teams that deploy frequently

Not ideal for

  • mobile app-store release cycles
  • desktop software with long release windows
  • firmware
  • heavy certification processes
  • products supporting many old versions

Practical policy

Branch from main.
Open pull request.
Require CI and review.
Merge to main.
Deploy from main.
Delete branch.
Code language: JavaScript (javascript)

13. Strategy 4: GitLab Flow

What it is

GitLab Flow adds deployment, environment, and release guidance around feature branches and merge requests. GitLab describes GitLab Flow as a simpler alternative to Gitflow that combines feature-driven development and feature branches with issue tracking, while allowing production and stable branches.

flowchart TD
    A[Feature branch] --> B[Merge request]
    B --> C[main]
    C --> D[staging]
    D --> E[production]
Code language: CSS (css)

Common GitLab Flow variants

Variant A: Main + production branch

main
production

Variant B: Environment branches

main
staging
production

Variant C: Release branches

main
release/1.0
release/1.1
release/2.0

GitLabโ€™s branching-strategy documentation describes models for web services, long-lived release branches, and branch-per-environment workflows.

Best for

  • teams using GitLab
  • staging โ†’ production promotion
  • enterprise web apps
  • release visibility
  • teams wanting more structure than GitHub Flow but less ceremony than Gitflow

Strength

GitLab Flow is a practical middle ground.

It says:

Keep development simple, but make deployment and release state explicit.

14. Strategy 5: Gitflow

What it is

Gitflow is a structured branching model with multiple long-lived and short-lived branches.

Typical branches:

main
develop
feature/*
release/*
hotfix/*

Atlassian describes Gitflow as assigning specific roles to branches such as feature, release, and hotfix branches, and notes that it is suitable for projects with scheduled release cycles.

gitGraph
    commit id: "prod-1"
    branch develop
    checkout develop
    commit id: "dev-1"
    branch feature/login
    checkout feature/login
    commit id: "login-work"
    checkout develop
    merge feature/login
    branch release/1.1.0
    checkout release/1.1.0
    commit id: "release-fix"
    checkout main
    merge release/1.1.0 tag: "v1.1.0"
    checkout develop
    merge release/1.1.0
    checkout main
    branch hotfix/1.1.1
    checkout hotfix/1.1.1
    commit id: "hotfix"
    checkout main
    merge hotfix/1.1.1 tag: "v1.1.1"
    checkout develop
    merge hotfix/1.1.1
Code language: JavaScript (javascript)

Branch roles

BranchPurpose
mainProduction-ready code
developIntegration branch for next release
feature/*New feature work
release/*Release stabilization
hotfix/*Emergency production repair
support/*Optional old-version maintenance

Best for

  • mobile apps
  • desktop apps
  • firmware
  • SDKs
  • on-prem software
  • scheduled release cycles
  • products needing formal release stabilization
  • teams supporting old versions

Pros

BenefitExplanation
Very structuredClear branch purpose
Release-friendlyGood for versioned products
Hotfix-friendlyProduction repair path is explicit
Governance-friendlyWorks with formal approval

Cons

RiskExplanation
More complexMany branch types
SlowerMore merging and coordination
develop can rotIf not protected
Long-lived branchesMore conflict risk
Overkill for SaaSContinuous delivery teams often do not need it

Verdict

Gitflow is powerful when release complexity is real.

It is overkill when a team can safely deploy from main.


15. Strategy 6: Trunk-based development

What it is

Trunk-based development means developers integrate small changes into one shared trunk frequently. The trunk-based development reference strongly recommends trunk-based development over models with multiple long-running branches and allows either direct-to-trunk commits for very small teams or short-lived pull-request branches.

gitGraph
    commit id: "A"
    branch tiny-change-1
    checkout tiny-change-1
    commit id: "B"
    checkout main
    merge tiny-change-1
    branch tiny-change-2
    checkout tiny-change-2
    commit id: "C"
    checkout main
    merge tiny-change-2
    commit id: "D"
Code language: JavaScript (javascript)

Branches

main
short-lived/*

Core rule

The trunk is the center of gravity.
Branches are temporary.

Best for

  • mature CI/CD teams
  • SaaS
  • APIs
  • platform teams
  • monorepos
  • high-frequency deployment
  • teams using feature flags
  • teams with strong automated tests

Required practices

PracticeWhy
Small PRsEasier review
Fast CIQuick feedback
Feature flagsHide incomplete work
Strong testsProtect trunk
Quick rollbackRecover safely
Short branch lifeAvoid merge pain

Warning

Trunk-based development does not mean chaos.

Bad trunk-based:

Everyone pushes random code to main.

Good trunk-based:

Small changes, strong CI, feature flags, protected main, fast rollback.
Code language: PHP (php)

16. Strategy 7: Release branch strategy

What it is

A release branch stabilizes a version while normal development continues elsewhere.

main
release/2.4.0
gitGraph
    commit id: "A"
    commit id: "B"
    branch release/2.4.0
    checkout release/2.4.0
    commit id: "rc-fix-1"
    commit id: "rc-fix-2"
    checkout main
    commit id: "future-work"
    checkout release/2.4.0
    commit id: "release-ready" tag: "v2.4.0"
Code language: JavaScript (javascript)

Best for

  • QA cycles
  • app-store approvals
  • enterprise release windows
  • certification
  • customer-specific versions
  • release candidates
  • controlled production promotion

Release branch rules

Allowed:

bug fixes
version bumps
release notes
safe documentation updates
release configuration fixes

Not allowed:

new features
large refactors
experimental changes
unrelated cleanup
risky dependency upgrades
Code language: JavaScript (javascript)

Good release branch naming

release/2.4.0
release/2026.07
release/mobile-5.1.0

17. Strategy 8: Environment branch strategy

What it is

Branches represent environments.

dev
staging
production
flowchart LR
    A[dev] --> B[staging]
    B --> C[production]
Code language: CSS (css)

Best for

  • simple deployment triggers
  • teams already using branch-based deployment
  • some GitLab Flow setups
  • smaller systems with strict promotion rules

Major risk: branch drift

flowchart TD
    A[main] --> B[staging]
    A --> C[production]
    B --> D[staging-only fix]
    C --> E[production-only hotfix]
    D --> F[Drift]
    E --> F
Code language: CSS (css)

Safe rules

If you use environment branches:

  1. Promotion direction must be clear.
  2. Never make random direct changes in production branch.
  3. Hotfixes must flow back to lower branches.
  4. CI must validate every promotion.
  5. Branch differences must be visible.
  6. Staging must not become a different product from production.

Better alternative for many teams

main branch + environment folders + deployment pipeline

Example:

environments/
  dev/
  staging/
  production/

18. Strategy 9: Fork-based strategy

What it is

Contributors fork the repository, work in their fork, and open pull requests to the upstream repository.

flowchart LR
    A[Upstream repository] --> B[Contributor fork]
    B --> C[Contributor branch]
    C --> D[Pull request]
    D --> E[Maintainer review]
    E --> F[Merge upstream]
Code language: CSS (css)

Best for

  • open-source projects
  • external contributors
  • vendors
  • public repositories
  • situations where contributors should not have write access

Typical flow

fork repo
create branch in fork
push changes
open pull request to upstream
maintainer reviews
merge

19. Strategy 10: GitOps branching strategy

What it is

GitOps uses Git as the desired state for infrastructure or application deployment.

flowchart LR
    A[App source repo] --> B[Build image]
    B --> C[Push image]
    C --> D[Update GitOps repo]
    D --> E[Argo CD / Flux sync]
    E --> F[Kubernetes cluster]
Code language: CSS (css)

Recommended layout

gitops/
  apps/
    auth/
    payment/
    notification/
  environments/
    dev/
    staging/
    production/
  platform/
    ingress/
    monitoring/
    security/

Best practice

For most GitOps teams:

Use one main branch and environment folders.
Code language: PHP (php)

This is often cleaner than long-lived environment branches.

Golden GitOps rule

Build once. Promote the same artifact.

20. Strategy 11: Monorepo branching strategy

What it is

A monorepo stores many apps, services, packages, and infrastructure code in one repository.

repo/
  apps/
    web/
    admin/
  services/
    auth/
    payment/
    notification/
  packages/
    common/
    ui/
  infra/
  docs/

Recommended strategy

trunk-based development
short-lived branches
CODEOWNERS
path-based CI
affected-project builds
feature flags
flowchart TD
    A[Change in monorepo] --> B[Detect changed paths]
    B --> C[Find affected projects]
    C --> D[Run targeted tests]
    D --> E[Request CODEOWNERS review]
    E --> F[Merge to main]
    F --> G[Build affected artifacts]
Code language: CSS (css)

Why trunk-based works well in monorepos

Long-lived branches in monorepos are especially painful because many teams touch the same repository. Short-lived branches and fast integration reduce conflict risk.


21. Strategy 12: Support / LTS branching strategy

What it is

Support branches maintain older versions.

main
release/3.0
support/2.x
support/1.9-lts
flowchart LR
    A[main] --> B[release/3.0]
    A --> C[support/2.x]
    A --> D[support/1.9-lts]
    E[Security fix] --> B
    E --> C
    E --> D
Code language: CSS (css)

Best for

  • enterprise products
  • SDKs
  • libraries
  • firmware
  • operating-system-like products
  • products with long customer upgrade cycles

Backport rule

A fix should be backported when it is:

  • security-related
  • data-loss-related
  • production-crash-related
  • compliance-related
  • customer-critical

Do not backport random refactors or new features unless there is a strong business reason.


22. Comparing branching strategies

StrategySpeedGovernanceComplexityBest for
MainlineHighLowLowTiny teams
Feature branchMedium-highMediumMediumMost teams
GitHub FlowHighMediumLow-mediumSaaS/web apps
GitLab FlowMediumHighMediumEnv promotion
GitflowMedium-lowHighHighVersioned releases
Trunk-basedVery highHigh if automatedMedium-highMature CI/CD
Release branchMediumHighMediumQA/release windows
Environment branchLow-mediumMediumMedium-highBranch deploys
Fork-basedMediumHighMediumOpen source
GitOpsHighHighMediumKubernetes/platform
Monorepo trunkVery highHighHigh toolingLarge repos
Support/LTSLow-mediumVery highHighOld versions

23. Strategy decision tree

flowchart TD
    A[Choose branching strategy] --> B{External contributors?}
    B -- Yes --> C[Fork-based strategy]
    B -- No --> D{Do you deploy many times per week?}
    D -- Yes --> E{Strong CI, tests, feature flags?}
    E -- Yes --> F[Trunk-based development]
    E -- No --> G[GitHub Flow or feature branch strategy]
    D -- No --> H{Scheduled versioned releases?}
    H -- Yes --> I{Need develop + release + hotfix structure?}
    I -- Yes --> J[Gitflow]
    I -- No --> K[Release branch strategy]
    H -- No --> L{Need staging to production promotion?}
    L -- Yes --> M[GitLab Flow or GitOps environment folders]
    L -- No --> N[Feature branch strategy]
Code language: PHP (php)

24. Recommended strategy by project type

Project typeRecommended strategy
Solo projectMainline
Small internal toolGitHub Flow
SaaS backendTrunk-based or GitHub Flow
Enterprise web appGitLab Flow
Mobile appRelease branches or Gitflow
Desktop appGitflow
FirmwareGitflow + support branches
SDK/libraryRelease branches + SemVer
Terraform IaCFeature branches + protected main
Kubernetes GitOpsMain + environment folders
Open sourceFork-based
MonorepoTrunk-based + CODEOWNERS
Regulated systemRelease branches + strict approval
Long-term enterprise productSupport/LTS branches

AWS Prescriptive Guidance groups common Git branching choices around trunk, GitHub Flow, and Gitflow and recommends choosing based on organizational needs.


25. The best default strategy for most modern teams

For most teams, start with this:

main
feature/*
bugfix/*
hotfix/*
release/* only when needed

Rules

  1. main is always healthy.
  2. No direct push to main.
  3. Every change goes through PR/MR.
  4. CI must pass before merge.
  5. At least one approval is required.
  6. Feature branches are short-lived.
  7. Release branches are created only for stabilization.
  8. Hotfix branches are created only for production emergencies.
  9. Branches are deleted after merge.
  10. Every production release is tagged.

GitHub protected branch rules can prevent force pushes or deletion and can require status checks, pull request reviews, or linear history before changes land.


26. Branch naming standard

Recommended format

<type>/<ticket-id>-<short-description>
Code language: HTML, XML (xml)

Examples

feature/EVP-123-add-device-search
bugfix/EVP-224-fix-login-timeout
hotfix/EVP-911-fix-prod-crash
release/2.4.0
support/1.9-lts
docs/EVP-410-update-runbook
chore/EVP-301-upgrade-dependencies
security/EVP-777-rotate-token
experiment/new-cache-design
Code language: JavaScript (javascript)

Branch prefix guide

PrefixPurpose
feature/New functionality
bugfix/Normal bug fix
hotfix/Urgent production fix
release/Release stabilization
support/Old-version maintenance
docs/Documentation
chore/Maintenance
refactor/Internal restructuring
security/Security fix
experiment/Temporary exploration
test/Test-only change

27. Branch protection strategy

Branching strategy is useless if it is not enforced.

Recommended branch protection

BranchProtection level
mainVery strong
release/*Strong
hotfix/*Fast but controlled
developStrong if used
productionVery strong
support/*Strong
feature/*Usually light

main protection checklist

- direct push disabled
- pull request required
- required CI checks
- required approvals
- CODEOWNERS for critical paths
- force push disabled
- branch deletion disabled
- signed commits if needed
- admin bypass audited

GitHub branch protection rules can enforce required reviews and passing status checks for pull requests before merge.


28. Merge strategy

A branching strategy must define how branches merge.

Merge options

Merge typeMeaningBest for
Merge commitPreserve full branch historyAudit-heavy teams
Squash mergeOne PR becomes one commitClean main
Rebase mergeReplay commits linearlyTeams with strong Git discipline
Fast-forwardMove pointer onlyTrunk/mainline workflows

Gitโ€™s documentation explains that git merge integrates another branch into the currently checked-out branch.

Recommended default

Normal feature PRs: squash merge
Release branches: merge commit
Hotfix branches: merge commit or squash depending audit need
Local cleanup: rebase your own branch
Shared branch: do not rebase casually
Code language: JavaScript (javascript)

29. Merge vs rebase

AreaMergeRebase
HistoryPreserves branch structureRewrites branch commits
SafetySafer for shared branchesSafer for local cleanup
ReadabilityCan be noisyLinear and clean
Conflict handlingUsually one merge conflict eventMay resolve conflicts commit by commit
Best useShared integrationCleaning your own branch

Safe rule

Rebase your own branch.
Do not rebase shared branches unless the team explicitly agrees.
Code language: PHP (php)

30. Release branch strategy in detail

A release branch exists to stabilize a version.

flowchart TD
    A[main/develop] --> B[Create release/2.5.0]
    B --> C[QA testing]
    C --> D[Bug fixes only]
    D --> E[Release candidate]
    E --> F[Tag v2.5.0]
    F --> G[Deploy/ship production]
Code language: CSS (css)

Release branch rules

Allowed:

fixes
version bump
release notes
safe documentation
release config correction

Not allowed:

new feature
big refactor
experimental dependency
unrelated cleanup
risky architecture change
Code language: JavaScript (javascript)

Release branch commands

git checkout main
git pull --ff-only origin main
git checkout -b release/2.5.0
git push -u origin release/2.5.0

After stabilization:

git checkout main
git merge --no-ff release/2.5.0
git tag -a v2.5.0 -m "Release v2.5.0"
git push origin main v2.5.0
Code language: JavaScript (javascript)

Semantic Versioning defines MAJOR.MINOR.PATCH, where major versions indicate incompatible API changes, minor versions add backward-compatible functionality, and patch versions add backward-compatible bug fixes.


31. Hotfix branch strategy in detail

Hotfix branches fix production fast but safely.

flowchart TD
    A[Production incident] --> B[Find production commit/tag]
    B --> C[Create hotfix branch]
    C --> D[Minimal fix]
    D --> E[Emergency PR]
    E --> F[Critical CI]
    F --> G[Merge]
    G --> H[Deploy]
    H --> I[Tag patch release]
    I --> J[Back-merge/cherry-pick to active branches]
Code language: CSS (css)

Hotfix rules

  1. Start from the production branch or production tag.
  2. Fix only the incident.
  3. Avoid refactoring.
  4. Avoid unrelated dependency upgrades.
  5. Keep PR small.
  6. Run critical CI.
  7. Deploy.
  8. Tag the patch release.
  9. Merge or cherry-pick back to main, develop, or active release branches.
  10. Create follow-up cleanup ticket if needed.

Hotfix commands

git checkout main
git pull --ff-only origin main
git checkout -b hotfix/2.5.1-payment-crash

After fix:

git add .
git commit -m "fix(payment): prevent crash on missing token"
git push -u origin hotfix/2.5.1-payment-crash
Code language: JavaScript (javascript)

After merge:

git checkout main
git pull --ff-only origin main
git tag -a v2.5.1 -m "Hotfix v2.5.1"
git push origin v2.5.1
Code language: CSS (css)

32. Support branch and backport strategy

Support branches exist when old versions need fixes.

flowchart LR
    A[Fix in main] --> B[Backport to release/3.0]
    A --> C[Backport to support/2.x]
    A --> D[Backport to support/1.9-lts]
    B --> E[Tag v3.0.4]
    C --> F[Tag v2.8.9]
    D --> G[Tag v1.9.17]
Code language: CSS (css)

Backport decision table

Change typeBackport?
Security vulnerabilityYes
Data lossYes
Production crashUsually yes
Compliance issueYes
Minor UI bugMaybe
New featureUsually no
RefactorNo

Backport command

git checkout support/2.x
git cherry-pick <fix-commit-sha>
git push origin support/2.x
Code language: HTML, XML (xml)

33. Branching and CI/CD

Branches should trigger different CI/CD behavior.

flowchart TD
    A[Branch pushed] --> B{Branch type?}
    B -- feature/* --> C[Lint + unit test + build]
    B -- main --> D[Full CI + deploy staging]
    B -- release/* --> E[Release validation]
    B -- hotfix/* --> F[Critical tests + fast checks]
    B -- production --> G[Production deploy]
    B -- support/* --> H[Version-specific tests]

Recommended pipeline behavior

BranchPipeline
feature/*lint, unit tests, build
bugfix/*lint, unit tests, build
mainfull CI, integration tests, deploy lower env
release/*full regression/release validation
hotfix/*critical CI, security check
support/*compatibility tests
productiondeploy only from approved artifact

34. Branching and feature flags

Feature flags are the secret weapon that lets teams keep branches short.

Without flags:

Feature not ready โ†’ keep branch open for weeks

With flags:

Feature not ready โ†’ merge safely behind disabled flag
flowchart TD
    A[Small feature branch] --> B[Code behind feature flag]
    B --> C[Merge to main]
    C --> D[Deploy with flag OFF]
    D --> E[Enable internally]
    E --> F[Enable 10%]
    F --> G[Enable 100%]
    G --> H[Remove old flag]
Code language: CSS (css)

Feature flag rules

  • Every flag has an owner.
  • Every flag has an expiry date.
  • Critical flags are monitored.
  • Old flags are removed.
  • Flag changes are auditable.
  • Flags should not become permanent configuration junk.

35. Branching and database migrations

Database migrations can destroy a beautiful branching strategy if handled badly.

Bad pattern

Large feature branch changes schema for 3 weeks.
Meanwhile main changes app behavior.
Release branch needs old schema.
Production hotfix now conflicts.

Safe pattern: expand โ†’ migrate โ†’ contract

flowchart LR
    A[Expand schema] --> B[Deploy backward-compatible app]
    B --> C[Backfill data]
    C --> D[Switch reads/writes]
    D --> E[Contract old schema]
Code language: CSS (css)

Rules

  1. Keep migrations small.
  2. Make schema changes backward compatible.
  3. Avoid destructive changes in the same release.
  4. Do not hide database changes inside huge PRs.
  5. Include rollback or fix-forward plan.
  6. Test old app + new schema and new app + old schema where needed.

36. Branching strategy for Infrastructure as Code

Infrastructure changes need stronger guardrails than normal app code.

Recommended branch model

main
feature/*
bugfix/*
hotfix/*

Usually avoid long-lived environment branches unless there is a very clear reason.

flowchart TD
    A[Create infra branch] --> B[Edit Terraform/Pulumi]
    B --> C[Format + validate]
    C --> D[Plan]
    D --> E[Security scan]
    E --> F[Cost/blast-radius review]
    F --> G[Approval]
    G --> H[Merge]
    H --> I[Apply via pipeline]
Code language: CSS (css)

IaC PR must include

  • plan summary
  • resources created
  • resources changed
  • resources destroyed
  • security impact
  • cost impact
  • blast radius
  • rollback plan

Dangerous plan keywords

destroy
replace
forces replacement
0.0.0.0/0
public access
delete database
disable encryption
remove backup
Code language: JavaScript (javascript)

37. Branching strategy for Kubernetes GitOps

For Kubernetes GitOps, avoid making branches too clever.

Recommended model

main
feature/*

Repository layout:

clusters/
  dev/
  staging/
  production/
apps/
  auth/
  payment/
  notification/
platform/
  ingress/
  monitoring/
  security/

Promotion flow

flowchart LR
    A[App PR merged] --> B[Build image]
    B --> C[Update dev manifest]
    C --> D[Promote same image to staging]
    D --> E[Promote same image to production]
    E --> F[Argo CD / Flux sync]
Code language: CSS (css)

GitOps rule

Git is desired state.
Production changes happen through reviewed Git changes.

38. Branching strategy for microservices

Microservices should not rely on branches to coordinate compatibility.

Use:

  • backward-compatible APIs
  • contract tests
  • versioned endpoints
  • feature flags
  • independent deployment
  • consumer-driven testing
  • observability

Bad microservice branching

service-a feature branch waits for service-b feature branch waits for service-c feature branch

This creates distributed merge hell.

Better

flowchart TD
    A[Service A change] --> B[Backward-compatible API]
    B --> C[Contract tests]
    C --> D[Deploy Service A]
    D --> E[Monitor consumers]
    E --> F[Gradual rollout]
Code language: CSS (css)

39. Branching strategy for monorepos

For monorepos, prefer:

main
short-lived feature branches
trunk-based development
CODEOWNERS
path-based CI
affected-project builds
feature flags

Monorepo branch flow

flowchart TD
    A[Change in repo] --> B[Detect changed paths]
    B --> C[Find affected services/packages]
    C --> D[Run targeted CI]
    D --> E[Request CODEOWNERS review]
    E --> F[Merge to main]
    F --> G[Build/deploy affected artifacts]
Code language: CSS (css)

Monorepo warning

Long-lived branches in monorepos are extra painful because many teams are modifying the same tree.


40. Branching strategy for mobile apps

Mobile apps often need release branches.

Recommended branches

main
feature/*
release/ios-5.0.0
release/android-5.0.0
hotfix/*

Mobile release flow

flowchart TD
    A[main] --> B[release/mobile-5.0.0]
    B --> C[QA]
    C --> D[App store submission]
    D --> E[Approval]
    E --> F[Staged rollout]
    F --> G[tag v5.0.0]
Code language: CSS (css)

Rules

  • Release branch receives stabilization fixes only.
  • Tags must match shipped builds.
  • APIs must remain backward compatible because old app versions stay in the wild.
  • Hotfixes may require patch release branches.

41. Branching strategy for libraries and SDKs

Libraries need stronger version discipline.

Recommended branches

main
release/*
support/*
hotfix/*

Rules

  • Use Semantic Versioning.
  • Tag every release.
  • Maintain changelog.
  • Backport critical fixes.
  • Breaking changes require major version.
  • Support branches exist for old major versions if needed.

Example

main              โ†’ v4 development
support/3.x       โ†’ v3 patches
support/2.x-lts   โ†’ v2 long-term support

42. Branching strategy for regulated systems

Regulated systems need traceability.

Recommended branches

main
release/*
hotfix/*
support/*

Required controls

  • protected branches
  • required reviewers
  • CODEOWNERS
  • required CI
  • release tags
  • deployment evidence
  • rollback plan
  • audit logs
  • signed commits if required
  • change ticket linkage
flowchart LR
    A[Ticket] --> B[Branch]
    B --> C[Commit]
    C --> D[PR approval]
    D --> E[CI result]
    E --> F[Release tag]
    F --> G[Deployment record]
    G --> H[Audit trail]
Code language: CSS (css)

43. Branch by abstraction

Branch by abstraction is how advanced teams avoid long-running branches during large changes.

flowchart TD
    A[Old implementation] --> B[Create abstraction]
    B --> C[Route old implementation through abstraction]
    C --> D[Add new implementation behind flag]
    D --> E[Migrate callers gradually]
    E --> F[Remove old implementation]
Code language: CSS (css)

Example

Instead of:

feature/new-payment-provider lives for 2 months
Code language: JavaScript (javascript)

Do:

PR 1: add PaymentProvider interface
PR 2: route old provider through interface
PR 3: add new provider behind flag
PR 4: migrate one flow
PR 5: migrate all flows
PR 6: remove old provider
Code language: JavaScript (javascript)

This keeps branches short and integration continuous.


44. Stacked branches

Stacked branches split large work into dependent PRs.

gitGraph
    commit id: "main"
    branch pr-1-abstraction
    checkout pr-1-abstraction
    commit id: "abstraction"
    branch pr-2-api
    checkout pr-2-api
    commit id: "api"
    branch pr-3-ui
    checkout pr-3-ui
    commit id: "ui"
Code language: JavaScript (javascript)

Use stacked branches when

  • work has natural layers
  • each layer can be reviewed separately
  • one giant PR would be terrible
  • changes can land progressively

Risk

Stacked branches require careful rebasing and clear communication.


45. Branching anti-patterns

Anti-pattern 1: Long-lived feature branches

feature/new-platform lives for 3 months
Code language: JavaScript (javascript)

Problem:

  • huge merge conflicts
  • hidden integration bugs
  • delayed feedback
  • big-bang release risk

Fix:

  • split work
  • use feature flags
  • use branch by abstraction
  • merge small pieces frequently

Anti-pattern 2: develop as a dumping ground

main is stable
develop is chaos

Problem:

  • develop always broken
  • releases start from unstable base
  • nobody owns quality

Fix:

  • protect develop
  • require CI
  • keep it green
  • remove it if not needed

Anti-pattern 3: Environment branches with direct fixes

production branch has hotfix
staging branch does not
main does not
nobody remembers

Fix:

  • hotfix branch from production
  • merge/cherry-pick back
  • automate branch comparison
  • never let production become secret code

Anti-pattern 4: Release branch becomes a feature branch

release/2.0 gets new dashboard feature
Code language: JavaScript (javascript)

Fix:

Release branches accept stabilization only.

Anti-pattern 5: No branch deletion

600 remote branches
nobody knows what matters

Fix:

  • auto-delete merged branches
  • prune stale branches
  • archive old release branches deliberately
  • review stale branches monthly

Anti-pattern 6: Branching instead of feature flags

Bad:

Keep code unmerged for weeks because feature is not ready.

Good:

Merge safely behind disabled feature flag.

46. Branching metrics

Measure your branching strategy.

MetricMeaning
Average branch ageIntegration delay
Stale branch countRepository hygiene
PR sizeReview quality
PR cycle timeDelivery speed
Merge conflict frequencyBranch drift
CI failure rateQuality health
Revert rateChange risk
Hotfix frequencyRelease quality
Deployment frequencyDelivery maturity

Healthy signals

feature branches live 1โ€“3 days
PRs are small
main is green
stale branches are low
hotfix rate is decreasing
rollback is fast

47. Branching commands cheat sheet

Create feature branch

git checkout main
git pull --ff-only origin main
git checkout -b feature/add-search

Push branch

git push -u origin feature/add-search

Update branch from main

Merge option:

git fetch origin
git merge origin/main

Rebase option:

git fetch origin
git rebase origin/main

Delete branch

Local:

git branch -d feature/add-search

Remote:

git push origin --delete feature/add-search
Code language: JavaScript (javascript)

List branches

git branch
git branch -a
git branch --merged

Prune deleted remote branches

git fetch --prune

Create release branch

git checkout main
git pull --ff-only origin main
git checkout -b release/2.5.0
git push -u origin release/2.5.0

Create hotfix branch

git checkout main
git pull --ff-only origin main
git checkout -b hotfix/2.5.1-payment-crash

48. Company-ready branching policy

Use this as a strong default.

Branching Strategy Policy

1. main is the primary integration branch.
2. main must always be healthy and releasable.
3. Direct push to main is not allowed.
4. All changes must go through pull requests or merge requests.
5. CI must pass before merge.
6. At least one approval is required.
7. CODEOWNERS approval is required for critical paths.
8. Feature branches must be short-lived.
9. Release branches are created only for release stabilization.
10. Hotfix branches are created only for production incidents.
11. Support branches are created only for maintained old versions.
12. Every production release must be tagged.
13. Branches must be deleted after merge.
14. Stale branches must be reviewed regularly.
15. Secrets must never be committed.
16. Infrastructure and database changes require explicit review.
17. Rollback strategy must be known before production deployment.
Code language: JavaScript (javascript)

49. One-page branching standard

Branches

main
feature/*
bugfix/*
hotfix/*
release/*
support/* only when needed

Merge rules

feature/* โ†’ main through PR
bugfix/* โ†’ main through PR
hotfix/* โ†’ main/release/support through emergency PR
release/* โ†’ main and tag
support/* โ†’ patch releases only

Protection rules

main: protected
release/*: protected
support/*: protected
hotfix/*: fast review
feature/*: normal review
Code language: HTTP (http)

Tagging rules

Production release: tag required
Hotfix release: patch tag required
Library release: SemVer tag required

Deletion rules

Merged feature branches: delete
Merged bugfix branches: delete
Old release branches: archive or delete based on policy
Support branches: keep while version is supported
Experiment branches: delete quickly
Code language: JavaScript (javascript)

50. Final branching blueprint

flowchart TD
    A[Work item] --> B{Type of work?}
    B -- Feature --> C[feature/* from main]
    B -- Bugfix --> D[bugfix/* from main]
    B -- Production incident --> E[hotfix/* from production tag/main]
    B -- Release stabilization --> F[release/*]
    B -- Old version fix --> G[support/*]

    C --> H[PR + CI + review]
    D --> H
    E --> I[Emergency PR + critical CI]
    F --> J[QA + fixes only]
    G --> K[Backport PR]

    H --> L[Merge to main]
    I --> L
    I --> M[Backport if needed]
    J --> N[Tag release]
    K --> O[Tag patch release]

    L --> P[Build artifact]
    N --> P
    O --> P
    P --> Q[Deploy / release]
    Q --> R[Observe]
    R --> S{Issue?}
    S -- Yes --> E
    S -- No --> T[Done]

51. Final recommendation

For most teams, the best practical strategy is:

Protected main
Short-lived feature branches
Pull requests / merge requests
Required CI
Required review
Squash merge for normal work
Release branches only when needed
Hotfix branches for production emergencies
Tags for production releases
Feature flags for incomplete work
Branch cleanup after merge
Code language: PHP (php)

Then evolve toward trunk-based development when your team has:

  • fast CI
  • strong automated tests
  • small PR culture
  • feature flags
  • reliable rollback
  • strong observability
  • mature review habits

Final principle:

Branches should reduce risk, not create bureaucracy.

A branch is valuable only if it helps with one of these:

  • safe collaboration
  • clean review
  • controlled release
  • emergency repair
  • old-version support
  • environment promotion
  • production traceability

If a branch does not do any of those things, simplify the model.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Trunk-Based Development Master Tutorial

From Beginner to Advanced: A Complete One-Stop Guide to Fast, Safe, Continuous Software Delivery 1. What is trunk-based development? Trunk-based development, often shortened as TBD, is a…

Read More

Gitflow Master Tutorial

From Basic to Advanced: A Complete One-Stop Guide to Gitflow Branching, Releases, Hotfixes, CI/CD, and Governance 1. What is Gitflow? Gitflow is a structured Git branching model…

Read More

Software Delivery Workflow Master Tutorial

From Beginner to Advanced: A Complete One-Stop Guide to Delivering Software Safely, Fast, and Reliably 1. What is software delivery workflow? A software delivery workflow is the…

Read More

Source Control Branching Model Master Tutorial

From Beginner to Advanced: A Complete One-Stop Guide for Designing Branching Strategies 1. What is a source control branching model? A source control branching model is the…

Read More

Version Control Workflow Master Tutorial

A Complete One-Stop Guide from Beginner to Enterprise Architecture 1. What is a version control workflow? A version control workflow is the complete process a team follows…

Read More

Git Workflow Master Tutorial

From First Commit to Enterprise-Grade Delivery Best title:Git Workflow Master Guide: Branching Strategies, Pull Requests, Releases, CI/CD, and Team Governance 1. What is a Git workflow? A…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x