Goal
Understand common branching strategies and when to use each.
Strategy 1: Trunk-based (recommended for fast teams)
Idea: main stays deployable; branches are short-lived.
Pattern:
- small branches
- frequent merges
- feature flags for incomplete work
Strategy 2: GitFlow (common in slower release cycles)
Branches:
mainproductiondevelopintegrationrelease/*stabilizationhotfix/*urgent production fixes
Strategy 3: Release branches (middle ground)
Idea: cut a release branch when needed, keep main moving.
Hotfix pattern (always)
git checkout -b hotfix/critical main
git commit -am "Fix critical bug"
git push -u origin hotfix/critical
Merge into main and any release branch.
How to choose (simple)
- small team, frequent deploys: trunk-based
- regulated, slow release cadence: release branches or GitFlow
- if you are unsure: trunk-based + release branches when needed
Exercises
- Simulate a hotfix branch.
- Merge it into main.
- Compare squash vs merge commits.
Next Step
Now connect Git to CI/CD: every merge should trigger build/test.