Branching Strategies
Table of Contents
- Trees vs Lanes
- Strategies
- Next
Trees vs Lanes
The strategies below are tree based strategies, not lane based strategies. Many lane based git diagrams you may have seen before are visually depicted horizontally (unlike actual git log graphs which are always vertical) and do not fit naturally with the data structure that git uses internally (a Merkle tree). Work committed in git does not tend to stay in lanes, but to diverge farther with each commit on a branch. Crossing lines in git diagrams generally indicate anti-patterns that make the repository difficult to maintain. The strategies below help minimize divergence and eliminate crossing merges.
Strategies
Mainline with Semantic Versioning
semver branches
semver/major
semver/minor
semver/patch
Disambiguate multiple same-level branches (see Example Hotfix): semver/patch-1.0.x
semver tags
production release: semver/1.0.0
pre-release: semver/1.0.0-wip001
deployment stage branches
pattern: stage/...
examples: stage/development
stage/qa
stage/beta
stage/production
Optionally, trigger pipelines with separate branches and only update stage branches after deployment is successful. stage/trigger/...
stage/trigger/development
stage/trigger/qa
stage/trigger/beta
stage/trigger/production
Feature Branches
pattern: feature/...
examples: feature/newFeature
merge plans: feature/mergePlan/...
feature/mergePlan/newFeature
Release Branches
pattern: release/...
examples: release/1.0.0
Strategy Details
- Mainline with Semantic Versioning
-
The gitbranch File - Start & End Branch Commits
-
Mainline Commits Must Pass Tests
-
Feature Branches
-
Don’t Span the Gap - Restart Branches After Merging
-
Plan Ahead Your Merge
-
Example Hotfix - Publishing A Patch on a Major Version
Test Code Isolation Branches
pattern: test/...
examples: test/semver/minor
test/feature/newFeature
Contributor Branch Namespaces
pattern: u/user.name/...
examples: u/user.name/semver/minor
u/user.name/feature/newFeature
u/user.name/wip
Other Branch Namespace
pattern: other/...
examples: other/archive/feature/newFeature-OLD_VERSION
Next
Mainline with Semantic Versioning
Table of contents
- Mainline with Semantic Versioning
- Test Code Isolation Branches
- Contributor Branch Namespaces
- Other Branch Namespaces