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.
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)
mainis always deployable.- Create a short-lived branch from
mainfor each change:git switch -c fix/invoice-rounding. - Commit, push and open a pull request early (draft PRs for early feedback).
- CI runs tests; teammates review (Code review).
- 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/* ●──● ●─●developcollects features;release/*branches stabilise a version;mainholds 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.
| Workflow | Branch lifetime | Best for |
|---|---|---|
| Trunk-based | Hours | Continuous delivery, strong CI, experienced teams |
| GitHub flow | Hours–days | Web services, most product teams |
| Release branches | Weeks (release only) | Mobile, versioned products |
| Git Flow | Long-lived develop/release | Multiple supported versions, scheduled releases |
| Forking | Varies | Open source |
Merge strategies
When a PR merges, you choose how its commits land on main:
| Strategy | Result | Pros | Cons |
|---|---|---|---|
| Merge commit | Branch commits + a merge commit | Preserves full history and branch context | Noisy, non-linear history |
| Squash and merge | One commit per PR | Clean, linear main; easy revert of a whole change | Loses granular commits (they remain in the PR) |
| Rebase and merge | Branch commits replayed linearly | Linear history with granular commits | Each 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 --rebaseorgit rebase main) for a clean history — only for branches you own (Git). - Or merge
maininto the branch — safer for shared branches. - Merge queues (GitHub, GitLab, Bors/Mergify) test each PR against the latest
mainplus everything ahead of it in the queue, somainnever 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 projects | Yes — change an API and all its callers in one PR | No — coordinate versions and releases |
| Code sharing and refactoring | Easy | Via published packages |
| Consistency of tooling | One set of tools and standards | Each repo diverges |
| Tooling needs | Smart builds: only build/test what changed (Bazel, Nx, Turborepo, Pants) | Standard tools suffice |
| Access control | Coarser | Per repository |
| Scale | Google, 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
mainfirst (with a test), then cherry-pick to the release branch or deploymainif 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
mainalways deployable. - Revert quickly when a merge breaks production; investigate after.
- 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.