Work Culture & Behind the Scenes

UK Cabinet Office-Style Branching: Short-Lived Branches, Mandatory Pull Requests and Main Branch Protection

The UK Cabinet Office digital handbook sets out concrete version control rules: short-lived branches, mandatory pull requests and a protected main. What does it say, and how can you apply it?

By Oemah Solution Editorial 5 min read

This article was prepared with AI assistance from the official sources listed below, and checked automatically before publication.

Moss-covered tree branches seen from below, reaching towards a blue sky through the forest canopy
Photo: Boxwood (Buxus) and Beech (Fagus) tree forest canopy, Mezmay, Russia by Vyacheslav Argenberg · CC BY 4.0 · Wikimedia Commons

On software projects with many contributors, a classic problem arises: half-finished code gets mixed with stable code, changes go in without review, and the history becomes hard to trace. The UK Cabinet Office Digital Handbook addresses this through its "Branching Strategies, Policies and Standards" guidance, which is binding rather than merely advisory. This article summarises its contents as learning material for development teams and for those who commission software.

Core principle: short-lived branches and a well-guarded main

According to the handbook, three principles must always be followed:

  • Use short-lived feature branches for all new features and bug fixes.
  • Merge feature branches into the main branch through a pull request (PR).
  • Keep the quality of main high and up to date.

Code on main must always pass tests and produce a clean build, so that every new branch starts from a stable version. Pushing directly to main is prohibited. The guidance also notes that branches are cheap, so creating a new branch even for a small fix is encouraged.

How it works in practice

Branch naming. The name of a feature branch links the work to a ticket in an issue tracking system such as JIRA or Azure DevOps. The format is ticketID-ticketTitle, with spaces replaced by hyphens. Example from the handbook: COPE-1333-deploy-aft-version-of-aws-requests-app-into-staging.

Feature flags. For features that take a long time, unfinished code may still be merged into main as long as it is hidden from users with a feature flag. This way, branches do not live for weeks.

Release branches. Ahead of a release, for example at the end of a sprint, a branch is created from main with a name such as release/20. Bugs are fixed on a new branch that originates from the release branch, then merged back through a PR. The fix must be ported to main through a separate PR to avoid regressions. Deployment branches (for example deploy/performance-test) are treated similarly, unless the team uses continuous deployment.

Commit messages. Each commit should be atomic, that is, one complete logical change. The structure is:

  • A one-line summary of at most 50 characters, in the imperative mood, with no full stop at the end.
  • One blank line.
  • A detailed explanation wrapped at 72 characters, focusing on why the change was made, not only what it contains.

Links to the issue tracker may be included, but they do not replace a good commit message.

PR responsibilities. The PR author is responsible for ensuring the PR is reviewed and merged, giving it a clear title and description, referencing related issues, linking a staging version for testing, and following up on blocking comments. Large pieces of work should be split into small PRs. Reviewers assess the purpose, scope, technical approach, code style, third-party dependencies, adequacy of tests including error cases, and the impact on deployment and documentation. The handbook cites research showing that two reviewers is the optimal number.

Branch protection: rules enforced by the system

Rules that exist only on paper are easily broken, so the handbook asks the Project Administrator to enable protection for main and release/* branches through the repository settings. The mandatory rules are:

  • A PR before merging.
  • Approval; at least one is recommended.
  • CI status checks, such as build and security scanning, must pass.
  • The branch must be up to date with the target.
  • All review conversations must be resolved.
  • No force pushes.
  • No branch deletion.

Additional options that may be considered: signed commits, linear history, and applying the rules to administrators. The handbook also recommends a CODEOWNERS file so that changes to critical areas, for example the .github/workflows/ folder, automatically request a review from the responsible team.

Pitfalls to avoid

  • Letting feature branches live too long, even though feature flags are available.
  • Writing commit messages that only explain what changed, without the reason.
  • Forgetting to port fixes from a release branch to main, so the same bug appears again.
  • Force pushing on a shared branch. The handbook prohibits it; if you must rewrite history on a personal branch, use git push --force-with-lease.
  • Using rebase to update a shared branch. The handbook recommends git merge because it preserves the original history.

Applying it in teams and for clients

For development teams, this guidance can serve as a starting point for internal standards: define the branch name format, PR template and commit rules, then enable branch protection so that discipline is enforced automatically rather than relying on memory.

For agencies or business owners who use vendor services, written rules like these can be included in development SOPs or contract appendices. Examples of points that can be requested: a ban on direct pushes to main, mandatory passing CI status checks, a minimum number of approvals, and a staging link on every PR. Because every change goes through a PR with a recorded review history, the audit trail is easier to follow and the risk of untested code reaching production is reduced.

#git#branching#pull-request#version-control#governance

Sources & references

This article is a summary and interpretation by the Oemah Solution team of the sources below. Refer to the original sources for full details and context.

  1. Strategi Branching ala Cabinet Office Inggris: Cabang Pendek, Pull Request Wajib, dan Proteksi Branch Utama UK Cabinet Office Digital Handbook · guidance.cabinetoffice.gov.uk