Why Branch Management Matters
- Development efficiency – A well-defined branching model prevents chaos, reduces communication ovrehead, and helps new members onboard quickly.
- Optimized CI/CD – Branch policies align with automated deployment, making builds and tests more reliable.
- Fewer merge conflicts – Standardized creation and merging practices clarify responsibilities and minimize collision.
Comparison of Common Git Branch Models
| Model | Key Branches | Best For |
|---|---|---|
| GitFlow | master, develop, feature/*, release/*, hotfix/* |
Large teams, scheduled releases |
| GitHub Flow | main, feature/* |
Continuous deployment, simple projects |
| GitLab Flow | production, main, develop, feature/* |
Environment‑aware deployments |
| Trunk‑Based | main, short‑lived feature/* |
CI‑heavy, small teams |
| AoneFlow (Ali) | master, feature/*, release/* |
Chinese enterprise DevOps |
The classic GitFlow uses a fixed set of branches: master for production, develop as the integration branch, feature/* for new work, release/* for release preparation, and hotfix/* for urgent fixes. GitHub Flow simplifies to a single main branch plus feature branches, ideal for continuous delivery. GitLab Flow introduces environment branches (e.g., production, staging). Trunk‑Based Development relies on very short‑lived feature branches and frequent merges to main.
Designing a Custom Flow: TripoFlow (Master‑Feature‑Env)
Our team (small, medium commit frequency, code review culture) needed something lighter than GitFlow but more structured than GitHub Flow. We created TripoFlow, named after three branch types: master, feature, and env.
master– The trunk; all feature branches originate here.feature/*– Developer branches for individual tasks; merged back intomaster.env/*– Environment branches (e.g.,env/test,env/staging); each maps to a deployed environment except production.
The diagram below illustrates the typical flow (using a Mermaid‑like representation):
gitGraph
commit id: "init"
branch feature/login
branch env/test
checkout feature/login
commit id: "develop feature"
checkout env/test
merge feature/login
checkout main
merge feature/login
branch release/v1.0.0
commit id: "release prep"
commit id: "bump version & build"
checkout env/test
commit id: "rebase master"
Development Workflow
- Create a
featurebranch frommaster. - Work on the feature, committing to the
featurebranch. Regularly rebase onmasterto stay current. - For testing, cherry‑pick the feature commits onto the
env/testbranch. CI/CD automatically builds and deploys to the test environment. - Once tested, open a Pull Request to
masterand request a code review. - After PR approval, the feature is complete.
Release Strategies
Agile Release (Continuous)
- Tag the
masterbranch with a version number. - Push the tag; CI/CD builds the artiafct.
- Manually deploy to production and monitor logs.
Iteration Release (Scheduled)
- Create a temporary
releasebranch frommaster. - Tag the release commit on that branch.
- CI/CD builds the package.
- Manually deploy, monitor, then delete the release branch.
Hotfix Procedure
- Identify the commit of the production tag. Create a
hotfixbranch from that commit. - Cherry‑pick the fix onto
env/testfor verification. If correct, retag. - Alternatively, create a
hotfixbranch frommaster, push it, and let CI/CD package it. - Once fixed, squash the hotfix commits into a single commit and merge it into
mastervia PR. - PR approved → fix deployed to master.
Writing Good Commit Messages
Every commit message should follow a consistent format to improve readability and automation. We adopt the Conventional Commits style:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
- type – One of:
feat,fix,docs,style,refactor,perf,test,chore. - scope (optional) – Module or area affected (e.g.,
auth,api). Use*for multiple scopes. - subject – Imperative present tense, no capital first letter, no trailing period.
- body – Explain the why and contrast with previous behavior.
- footer – Note breaking changes (
BREAKING CHANGE:) and reference related issues (e.g.,Closes #123).
Example:
feat(auth): implement JWT‑based authentication
Add login endpoint, token generation, and refresh mechanism.
This replaces the basic auth scheme and improves security.
BREAKING CHANGE:
- All API requests must now include a JWT token in the header.
- Basic authentication is no longer supported.
Closes #123