Branching Strategy
Source: Confluence - Branching Strategy
Overview
A branching strategy is the approach that software development teams adopt when writing, merging, and deploying code when using a version control system (VCS). It is essentially a set of rules that developers can follow to stipulate how they interact with a shared codebase.
Adhering to a branching strategy will:
- Keep repositories organized
- Assist with merging code bases
- Allow developers to work together without stepping on each other’s toes
- Enable teams to work in parallel for faster releases and fewer conflicts
Git and Bitbucket
- VCS: Git
- Remote Repository: Bitbucket - Path2Response
origin: Shorthand for the remote repository (source of truth)
Branching Strategies Overview
Path2Response’s branching strategy draws from the best of common strategies:
Path2Response Branching Strategy
Main Branch
The primary code base is the main branch.
origin/mainis whereHEADreflects our current code base- Represents what is intended to be in production (not necessarily what is deployed)
- All deployments to production are generated from this branch
- Reflects a state with the latest delivered development changes for the next release
Note: Historically the default was
master, now it’smain.
Feature Branch
Feature branches allow developers to work together without constant merge conflicts.
Naming Convention: Use the Jira issue key (e.g., PATH-1234)
Guidelines:
- All development should be done on feature branches
- No development directly on
main - Commit code to the feature branch constantly
- Push to
originwhen ready (at end of development for solo work) - Routinely pull
mainand merge into your feature branch (at least daily for multi-day features) - We do not rebase our branches - just merge and keep individual commits intact
Feature branches are temporal:
- Typically don’t exist longer than a sprint or two
- Delete after cleanup period (after one sprint post-release)
Epic Branches: For complex work spanning multiple sprints:
- Work for each issue under Epic is done on the Epic branch, or
- Work for each issue is done on its own feature branch, then merged into Epic branch
Development Branch
The dev branch is where work from feature branches is placed for testing in an isolated development environment.
Note: Currently, the
devbranch does not exist in our repositories. This will change in the near future.
Purpose:
- Test features in isolation before integration
- Alternative to serverless: feature branch deployed to its own environment
Staging Branch
The staging branch is where all code (typically from all feature branches) is placed for integration testing during a sprint.
Purpose:
- First opportunity for integration testing across developers
- Can expose problems when two feature branches work in isolation but break together
- Intended for developers (not stakeholders)
Current State: We are using
stagingforacceptance. This will change when projects move to serverless.
Acceptance Branch
The acceptance branch contains code to be reviewed and (hopefully) accepted by stakeholders.
Note: Currently, the
acceptancebranch does not exist and there is no acceptance environment. This will change in the near future.
Tag for Release
At the completion of each sprint, the code on main is tagged with the sprint version.
Tag Format: 249.0.0 (sprint number followed by .0.0)
What happens:
- Commit to
mainupdates the version to the official sprint version - Tag is created referencing that commit
- All work for the next sprint includes code from the tagged state
Production Branch
The production branch provides clear separation between the primary code base and the production environment.
Advantages:
- Clear code base representing what is on the production environment
- Enables CI/CD using the
productionbranch for continuous delivery
Access: Merging to
productionis restricted and not available to most developers.
Release Candidate Branch
The release_candidate branch is where code is merged to for pre-release testing.
Environment: “rc” (release candidate environment)
Note: “release candidate” for branch name, “rc” for environment to avoid confusion.
Sprint Release Activities
Reset Branches
At the start of each sprint, branches are reset to the previous sprint’s tag:
dev,staging,acceptance, andrelease_candidateare reset to the previous sprint’s tag- Versions are then set to
250.0.0-SNAPSHOT(indicating temporal snapshot leading to release)
Sprint Release Process
During Development Sprint Planning:
- Tag Release - Tag
mainwith sprint version - Set Pre-Release Versions - Update version numbers
- Reset Staging Branches - Reset all branches from the tag
Sprint Timeline:
- Sprint Retrospective → branches/environments reset
- Pre-release testing on rc environment
- Production approval from Production team
- Sprint tag pushed to
productionand deployed
Hotfix and Patch Process
Hotfix Branch
For issues requiring immediate resolution that can’t wait for the next sprint release.
Creation:
- Create from
mainthat was deployed to production - Named after the Jira issue (e.g.,
PATH-1235)
Testing Hot Fix
- If bug can be isolated, merge hotfix branch to
devand deploy to development environment - Be careful: sprint code may not match production, creating testing challenges
Patch Branch
The patch branch manages and deploys the hotfix to production.
Important: Created from the last tag deployed to production, NOT from main or production.
Naming Conventions:
patch_{Tag Version}(e.g.,patch_250.1.0)patch_{Jira Issue}_{Intended Patch Version}(e.g.,patch_PATH-1235_250.1.0)
Version name must match across patch branch, internal version, and tag.
Patch Workflow
- Cherry-pick commits from hotfix branch to patch branch (don’t merge entire branch)
- Update version information on patch branch
- Create pull requests for both feature branch (to
main) and patch branch (toproduction) - Tag the patch using annotated tags
- Deploy from the tag to production
- Merge fix to main - hotfix branch goes through normal PR and acceptance process
Summary
| Branch | Purpose | Deployed To |
|---|---|---|
main | Primary code base, production-ready state | — |
Feature (PATH-####) | Individual development work | — |
dev | Developer testing (isolated) | Development env |
staging | Integration testing | Staging env |
acceptance | Stakeholder acceptance | Acceptance env |
release_candidate | Pre-release testing | RC env |
production | Production deployment source | Production env |
Patch (patch_###.#.#) | Hotfix deployment | Production env |
Key Principles
- Never develop directly on
main - Name branches after Jira issues
- Merge
maininto feature branches regularly (at least daily) - Don’t rebase - just merge
- Patches come from tags, not
main - Cherry-pick hotfixes to patches, don’t merge entire branches
- Use annotated tags for releases