Version Control Workflows

How teams collaborate with Git — centralised vs feature-branch workflows, GitHub flow, Git Flow, trunk-based development, pull requests, merge strategies (merge, squash, rebase), branch protection, monorepos vs polyrepos, and handling releases and hotfixes.

Intermediate 5 min readLesson 7 of 9

Git gives you branches, merges and rebases. A workflow is the team agreement on how to use them: where work happens, how it's reviewed, how it reaches production. The right workflow keeps integration painless and releases boring.

The core tension: integration frequency

Every branch is a divergence from everyone else's work. The longer branches live, the bigger and riskier the eventual merge ("merge hell"), and the later you discover that two changes conflict in behaviour, not just text. Modern practice pushes toward integrating small changes frequently.

Common workflows

Feature branches with pull requests (GitHub flow)

  1. main is always deployable.
  2. Create a short-lived branch from main for each change: git switch -c fix/invoice-rounding.
  3. Commit, push and open a pull request early (draft PRs for early feedback).
  4. CI runs tests; teammates review (Code review).
  5. Merge to main — and deploy (often automatically).

Simple and effective for web services with continuous deployment. Works best when branches live hours to a couple of days.

Trunk-based development

Everyone integrates into a single branch (main/trunk) at least daily, either directly (with pair programming and strong CI) or via very short-lived branches and small PRs.

  • Unfinished features hide behind feature flags, so incomplete code can merge safely (CI/CD).
  • Large changes use branch by abstraction: introduce an interface, migrate callers gradually, switch implementations, delete the old one — all on trunk.
  • Requires fast, reliable CI and a culture of small commits.

Research behind the DORA metrics links trunk-based development with higher delivery performance. It's how Google, Meta and many high-performing teams work (often in a monorepo).

Git Flow

A heavier model (2010) with long-lived branches:

main       ●────────────●──────────────●        (tagged releases only)
            \          / \            /
hotfix/*     \        /   ●──hotfix──●
              \      /
release/*      \    ●──stabilise──●
                \  /               \
develop  ●───●───●────●────●────●───●───        (integration branch)
              \     /        \   /
feature/*      ●──●           ●─●
  • develop collects features; release/* branches stabilise a version; main holds released code; hotfix/* patches production.
  • Suits software with explicit, versioned releases shipped to customers (desktop apps, mobile apps with store review, on-premises products, libraries supporting multiple versions).
  • For continuously deployed web services it's usually overkill: long-lived branches delay integration and add merge overhead. Its author later recommended simpler flows for such teams.

Release branches (a middle ground)

Develop on trunk; cut a release/2.4 branch when stabilising a version; cherry-pick fixes from trunk to the release branch (fix on trunk first, so the fix isn't lost). Common for mobile apps and products with support windows.

Forking workflow

Contributors fork the repository, push to their fork, and open PRs to the upstream project. Standard for open source, where contributors don't have write access.

WorkflowBranch lifetimeBest for
Trunk-basedHoursContinuous delivery, strong CI, experienced teams
GitHub flowHours–daysWeb services, most product teams
Release branchesWeeks (release only)Mobile, versioned products
Git FlowLong-lived develop/releaseMultiple supported versions, scheduled releases
ForkingVariesOpen source

Merge strategies

When a PR merges, you choose how its commits land on main:

StrategyResultProsCons
Merge commitBranch commits + a merge commitPreserves full history and branch contextNoisy, non-linear history
Squash and mergeOne commit per PRClean, linear main; easy revert of a whole changeLoses granular commits (they remain in the PR)
Rebase and mergeBranch commits replayed linearlyLinear history with granular commitsEach commit must be meaningful and pass tests; rewrites hashes

Many teams squash by default: each commit on main = one reviewed change with a good message, which makes git log, git bisect and reverts simple (Debugging).

Keeping branches up to date

  • Rebase your feature branch on main (git pull --rebase or git rebase main) for a clean history — only for branches you own (Git).
  • Or merge main into the branch — safer for shared branches.
  • Merge queues (GitHub, GitLab, Bors/Mergify) test each PR against the latest main plus everything ahead of it in the queue, so main never breaks from two individually green PRs that conflict semantically.

Branch protection and policies

  • Protect main: require PRs, passing CI checks, at least one approval, up-to-date branches or a merge queue; block force pushes.
  • CODEOWNERS routes reviews to the right people.
  • Require signed commits where provenance matters.
  • Conventional Commits (feat:, fix:, chore:) enable automated changelogs and version bumps (Semantic versioning).
  • Branch naming conventions: feat/…, fix/…, ticket IDs.
  • Pre-commit hooks for formatting, linting and secret scanning.

Monorepo vs polyrepo

Monorepo (one repository for many projects)Polyrepo (one repository per service/library)
Atomic changes across projectsYes — change an API and all its callers in one PRNo — coordinate versions and releases
Code sharing and refactoringEasyVia published packages
Consistency of toolingOne set of tools and standardsEach repo diverges
Tooling needsSmart builds: only build/test what changed (Bazel, Nx, Turborepo, Pants)Standard tools suffice
Access controlCoarserPer repository
ScaleGoogle, Meta, Microsoft (huge, custom tooling)Common with microservices

Neither is universally better; the deciding factors are how often changes span projects and how much tooling investment you can make.

Releases and hotfixes

  • Tag releases (v2.4.1) and generate changelogs from commit history.
  • Hotfix flow: fix on main first (with a test), then cherry-pick to the release branch or deploy main if it's releasable. Avoid fixing only the release branch — the bug returns in the next release.
  • With continuous deployment, a hotfix is just a normal small PR — another argument for keeping main always deployable.
  • Revert quickly when a merge breaks production; investigate after.
Key takeaways
  • Workflows trade off integration frequency against isolation; long-lived branches cause painful merges.
  • GitHub flow: short-lived branches + PRs + deployable main — the common default.
  • Trunk-based development integrates at least daily, using feature flags and branch by abstraction.
  • Git Flow and release branches suit versioned, scheduled releases; they're overkill for continuous deployment.
  • Squash merges keep main linear and easy to bisect and revert; merge queues keep main green.
  • Protect main with CI, reviews and CODEOWNERS; choose monorepo or polyrepo based on cross-project change frequency and tooling.