appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

Branching strategies and release flow

Lesson 4 of 411 minAdvanced

Pick a workflow that fits your team: trunk-based, feature branches or release branches.

Git does not impose a workflow. Choose one that fits how often you release and how many people work in parallel.

StrategyHow it worksGood for
Trunk-basedEveryone merges small changes into main at least daily, behind feature flags when neededTeams that deploy continuously and have good tests
Feature branches + PROne short-lived branch per change, reviewed and merged into mainMost teams. Keep branches under a few days
Release branchesA release/1.4 branch is stabilised while main moves on. Fixes are cherry-pickedSoftware with versions that must be supported in parallel

How to merge a PR

  • Merge commit: keeps every commit and records the merge. History is accurate and noisy.
  • Squash and merge: one commit per PR. History is clean, but you lose the individual commits.
  • Rebase and merge: replays commits linearly, with no merge commit.

Protect main

  • Require a pull request and at least one review.
  • Require the tests (CI) to pass.
  • Forbid force pushes and deletion of main.
  • Use semantic version tags (v1.4.2) for releases.

NoteLong-lived branches are the main source of painful merges. Whatever the strategy, the shorter a branch lives, the easier life is.

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

1. Which strategy keeps branches very short and merges to main at least daily?
2. What does squash and merge produce?
3. Which setting protects main from accidents?

Key terms