| file_type | documentation | ||||
|---|---|---|---|---|---|
| title | Org-wide Git Branching Strategy | ||||
| description | Canonical branch naming, protection, merge discipline, and automation rules for LightSpeedWP repositories. | ||||
| last_updated | 2026-06-09 | ||||
| owners |
|
||||
| version | v1.5 | ||||
| status | active | ||||
| stability | stable | ||||
| domain | governance | ||||
| tags |
|
||||
| language | en |
Primary operations reference: GITHUB_PROJECT_OPERATIONS_SPEC.md
Keep main always deployable, reduce merge risk, and make PR automation predictable across all LightSpeedWP repositories. This policy aligns branch names with Issue Types and Projects, powers label and workflow automation, and enforces disciplined merge practices.
mainis production-ready at all times.- Optional
developbranch for integration workflows. - Short-lived branches; open PRs early and keep changes small.
- Squash merge to preserve linear history; delete branches post-merge.
- Use branch prefixes that map cleanly to Issue Types and Project fields.
Apply these GitHub protection rules to main (and develop if used):
- Require pull request before merging.
- Require approvals: 1 for most repos, 2 for critical repos.
- Require review from Code Owners (if using
CODEOWNERS). - Dismiss stale approvals when new commits are pushed.
- Require conversation resolution before merging.
- Require status checks to pass before merging (lint, tests, build).
- Require branches to be up to date before merging.
- Require linear history (squash-merge only).
- Do not allow bypassing (include administrators).
- Optionally require signed commits.
Enable squash merge only; disable merge commits and rebase merges.
Format:
{type}/{scope}-{short-title}
Use lower-case, kebab-case, and keep it short.
For all repos (client, product, infra, etc.), use:
feat/— new capability/featurefix/— bug fixhotfix/— urgent production fixrelease/— release branches (e.g.,release/v1.6.0)refactor/— internal restructurechore/— maintenance, housekeepingdocs/— documentationtest/— testing onlyperf/— performance improvementsci/— CI/CD or workflow changesbuild/— build process changesdeps/— dependency updatessecurity/— security-relatedrevert/— revert previous changesresearch/— research spikesdesign/— design changesa11y/— accessibility changesux/— user experiencei18n/— internationalizationops/— operations
proto/— prototypes/experimentsds/— design systemapi/— API surfaceschema/— DB/schema changestelemetry/— analytics/metrics
content/— content edits, redirects, IAseo/— SEO, metadata, schema, sitemap, robotsconfig/— site/plugin configurationmigrate/— data/content migrationsqa/— test harnesses, UAT scaffoldinguat/— UAT-only changes or staging togglescodex/— Codex-assisted work branches used by the local agent workflow
feat/product-grid-quick-add
refactor/split-frontend-bundle
api/orders-bulk-cancel
schema/add-index-orders-created
telemetry/add-checkout-step-events
release/v1.6.0
hotfix/cart-csrf-check
fix/nl-postcode-validation
content/category-copy-refresh
config/feature-flags-cart
seo/add-faq-schema-on-product
release/go-live-2025-10-10
hotfix/ga4-purchase-duplicate
- Validate branch relevance before the first edit.
- If the current branch belongs to a different issue, PR, or task, create a new branch from
developbefore making changes. - Do not reuse in-flight branches for unrelated work, even when the working tree is already open.
- If unrelated local changes are present, use a clean worktree rather than mixing scopes.
- Temporary audit replay branches created for PR merge prep may use the form
pr-<number>-auditwhen they need to keep a live PR attached to a historical review branch.
Use a single regex in a workflow to enforce naming discipline:
^(feat|fix|hotfix|release|refactor|chore|docs|test|perf|ci|build|deps|security|revert|research|design|a11y|ux|i18n|ops|proto|ds|api|schema|telemetry|content|seo|config|migrate|qa|uat|codex)/[a-zA-Z0-9._-]+$Example workflow (.github/workflows/validate-branch-name.yml):
name: Validate branch name
on:
pull_request:
types: [opened, reopened, synchronize, edited, ready_for_review]
jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Enforce {type}/{scope}-{short-title}
run: |
BRANCH="${{ github.head_ref }}"
# Allow dependabot/renovate
if [[ "$BRANCH" =~ ^(dependabot|renovate)/ ]]; then exit 0; fi
# Allow temporary audit replay branches used for PR merge prep
if [[ "$BRANCH" =~ ^pr-[0-9]+-audit$ ]]; then exit 0; fi
if [[ ! "$BRANCH" =~ ^(feat|fix|hotfix|release|refactor|chore|docs|test|perf|ci|build|deps|security|revert|research|design|a11y|ux|i18n|ops|proto|ds|api|schema|telemetry|content|seo|config|migrate|qa|uat)/[a-zA-Z0-9._-]+$ ]]; then
echo "❌ Branch '$BRANCH' must match the required pattern."
exit 1
fi[NEW]
- For monorepos, ensure branch naming applies to each package/subproject, or use a consistent prefix (e.g.
feat/frontend-...,fix/api-...). - For forked repos, always clean up branches after merging upstream PRs, and avoid duplicating branch names across forks to prevent confusion.
Ensure .github/labeler.yml seeds new PRs with status:needs-review when appropriate:
"status:needs-review":
- head-branch:
[
"^feat/.*",
"^fix/.*",
"^hotfix/.*",
"^release/.*",
"^refactor/.*",
"^chore/.*",
"^docs/.*",
"^test/.*",
"^perf/.*",
"^ci/.*",
"^build/.*",
"^deps/.*",
"^security/.*",
"^revert/.*",
"^research/.*",
"^design/.*",
"^a11y/.*",
"^ux/.*",
"^i18n/.*",
"^ops/.*",
"^proto/.*",
"^ds/.*",
"^api/.*",
"^schema/.*",
"^telemetry/.*",
"^content/.*",
"^seo/.*",
"^config/.*",
"^migrate/.*",
"^qa/.*",
"^uat/.*",
][NEW]
- For automation, use GitHub Actions to auto-assign reviewers based on branch type (e.g., security → security lead).
- Sync project automation rules across all repos using
.githubrepo templates.
Extend your project sync workflow so branch prefixes set the Project Type field:
feat/→ Feature/Storyfix/→ Bug (hotfix → critical Bug)refactor/→ Refactorchore/,ci/,build/,deps/,security/→ Choredesign/,a11y/,ux/→ Design/Taskcontent/,seo/,config/,migrate/,qa/,uat/→ Task/Operationsproto/,api/,schema/,telemetry/,ds/→ Feature/Taskrelease/→ Release PR
Principle: Labels remain routing signals (status, priority, area/component). Issue Types and Project fields carry the semantic meaning.
Use .github/PULL_REQUEST_TEMPLATE/config.yml as the canonical machine-readable
route map, and keep it aligned with the branch names and template files below.
Where there is no specialised template file, the closest active template is
reused so automation stays predictable.
| Branch prefix | PR template |
|---|---|
feat/ |
pr_feature.md |
fix/ |
pr_bug.md |
hotfix/ |
pr_hotfix.md |
refactor/ |
pr_refactor.md |
chore/ |
pr_chore.md |
docs/ |
pr_docs.md |
test/ |
pr_chore.md |
perf/ |
pr_feature.md |
ci/ |
pr_ci.md |
build/ |
pr_ci.md |
deps/ |
pr_dep_update.md |
security/ |
pr_bug.md |
design/ |
pr_feature.md |
a11y/ |
pr_feature.md |
ux/ |
pr_feature.md |
release/ |
pr_release.md |
research/ |
pr_feature.md |
revert/ |
pr_chore.md |
i18n/ |
pr_feature.md |
ops/ |
pr_chore.md |
proto/ |
pr_feature.md |
ds/ |
pr_feature.md |
api/ |
pr_feature.md |
schema/ |
pr_feature.md |
telemetry/ |
pr_feature.md |
content/ |
pr_docs.md |
seo/ |
pr_docs.md |
config/ |
pr_chore.md |
migrate/ |
pr_chore.md |
qa/ |
pr_chore.md |
uat/ |
pr_chore.md |
- Keep branches current; resolve all conversations before merging.
- Squash merge only; PR title becomes the squash commit.
- Delete the branch after merge. [NEW]
- Never force push to shared branches (
main,develop); use protected branch settings. - For remote teams, always communicate in PR comments and reference related issues for traceability.
- Release: Open
release/vX.Y.Z, bump versions and changelog, run full CI, QA on staging, merge tomain, tag, deploy. - Hotfix: Branch from
mainashotfix/<slug>, minimal fix, PR tomain, tag, cherry-pick/back-merge todevelop(if used). [NEW] - Always update release notes and changelog for each release/hotfix, even when changes seem minor.
- Enable branch protections on
main(+developif used). - Adopt branch naming discipline; enforce via CI workflow.
- Sync
.github/labeler.ymland project mapping with chosen prefixes. - Prefer Issue Types and Project fields over proliferation of
type:*labels. - Squash merge only; delete branches post-merge.
- Share this strategy in repo READMEs and onboarding docs. [NEW]
- Document exceptions (e.g., legacy branches, vendor integrations) in
CONTRIBUTING.md.
- Do we need
develop? Optional; skip if deployment model supports feature/release branches. - Where do we record “type of work”? Project Type field (from branch) and Issue Type on linked issue.
- How do
type:*labels work? Issue Types are the primary classification;type:*labels are automation-managed companions applied by the labeling agent for routing, reporting, and project mapping. - Can we add prefixes? Yes—extend CI regex and project mapping together.
[NEW]
- What if a branch is incorrectly named? CI will block the PR from merging; rename the branch and re-open the PR.
- How do I handle urgent fixes outside business hours? Use
hotfix/, notify the team via Slack/Teams, and ensure all protections are respected.
- BRANCHING_STRATEGY.md: Org-wide branch naming, merge discipline, and automation mapping.
- CHANGELOG.md: Changelog format, release notes, and versioning.
- CONTRIBUTING.md: Contribution guidelines, templates, and coding standards.
- GITHUB_PROJECT_OPERATIONS_SPEC.md: Org-wide project operations, labeling, and release guidance.
- ISSUE_TYPES.md: Issue type mapping and usage.
- LABELING.md: Consolidated label documentation (issue, PR, and discussion labeling).
- Issue labelling: Issue label requirements and automation.
- Pull request labelling: PR label requirements and automation.
- .github/custom-instructions.md: Copilot and agent instructions.
- instructions/linting.instructions.md: Linting index and tool guidance.
- instructions/coding-standards.instructions.md: Coding standards index.
- instructions/documentation-formats.instructions.md: Frontmatter schema and conventions.
- GitHub Custom Instructions: Org-wide guidance and AI agent usage.
- Pull Request Template: PR summary and best practices.
- Create or update org-level
.githubdefaults (workflows, labeler, protections). - Sync labels using
gh labelor.github/labels.yml. - Add branch protection rules to every repo.
- Share this policy in repo README and onboarding documentation.
- Enforce via CI and maintain with regular review.
- For monorepos, coordinate releases and branch protection across all workspaces.
- If CI blocks a merge due to naming, run
git branch -m <old> <new>locally, then push and re-open PR. - Use GitHub Branch Protection API for automation.
- Escalate persistent issues to Engineering leads via issue or Slack.
- New contributors must review this document and complete onboarding modules.
- Include branch naming and merge training in onboarding sessions.
- Add cheat sheets and workflow diagrams to internal wiki.