-
Notifications
You must be signed in to change notification settings - Fork 0
Contribution 101
- Git Flow
- Trunk Based Development
- Comparison of Git Flow and Trunk Based Development
- Task Status Transitions and Best Practices
- Analysis of the Two Approaches
- Feasibility of Using Both Approaches for Two Teams
- Recommendations for Implementation
- Conclusion
-
main: the main branch containing stable production-ready code. -
dev: the branch for integrating changes intended for the next release. -
test: the branch for testing release changes.
-
release/*: branches intended for preparing and testing releases.- Example:
release/generic:v1.0.0for a general release orrelease/somePartnerAlt1:v1.0.1for a partner-specific release.
- Example:
- After completion, the release branch is merged into
mainanddev.
main
|
|----------> release/* ----------> main
| |
| |
| v
|----------> test ---------------> main
| ^
| |
|----------> dev ----------------> release/*
^
|
|---------------------> feat/* or hotfix/*
-
Creating a New Branch:
- For developing a new feature or fix, create a branch from
dev:git checkout -b feat/yourFeatureName dev
- For developing a new feature or fix, create a branch from
-
Regular Updates from
dev:- Regularly synchronize your branch with the latest state of
dev:git pull origin dev
- This minimizes the risk of conflicts during merging.
- Regularly synchronize your branch with the latest state of
-
Sync Before Creating a Pull Request:
- Ensure your branch is fully synchronized with
devbefore creating a Pull Request:git pull origin dev git push origin feat/yourFeatureName
- Ensure your branch is fully synchronized with
-
Creating a Pull Request:
- After completing your work, create a Pull Request to the appropriate release branch (e.g.,
release/generic:v1.0.0).
- After completing your work, create a Pull Request to the appropriate release branch (e.g.,
-
For Adding New Features:
feat: brief description of the added feature detailed description of changes -
For Fixing Bugs:
fix: brief description of the fix detailed description of changes
-
Task Statuses:
-
backlog: the task is in the backlog. -
todo: the task is ready to start. -
in progress: the task is in progress (a branch is created, e.g.,feat/someNewFunc). -
testing: the task is being tested (testing is performed on the feature branch). -
rework: the task is returned for rework after failed testing. -
code review: the task is under code review before merging. -
pre-deploy: the task undergoes smoke testing on the release branch. -
done: the task is completed, and changes are merged intomain.
-
-
Step-by-Step Process:
-
Step 1: Move the task from
backlogtotodo. -
Step 2: Move the task to
in progressand create a branch:git checkout -b feat/someNewFunc dev
-
Step 3: Regularly update your branch:
git pull origin dev
-
Step 4: After completing the work, move the task to
testingand test the changes on the feature branch. -
Step 5: If testing fails, move the task to
reworkand make the necessary fixes. -
Step 6: After successful testing, create a Pull Request to the release branch and move the task to
code review. -
Step 7: After successful code review, move the task to
pre-deployand perform smoke testing on thetestbranch. -
Step 8: After successful testing, merge the changes into
devandmain, and move the task todone.
-
Step 1: Move the task from
-
Testing on the Feature Branch:
- All changes must be tested on the feature branch before creating a Pull Request.
-
Smoke Testing:
- After merging changes into the release branch, perform smoke testing on the
testbranch.
- After merging changes into the release branch, perform smoke testing on the
-
Regular Updates from
dev:- Regularly pull changes from the
devbranch during development:git pull origin dev
- This ensures your branch remains up-to-date and reduces the likelihood of conflicts.
- Regularly pull changes from the
-
Example Workflow:
- Create a new branch for development:
git checkout -b feat/addNewButton dev
- Regularly update your branch:
git pull origin dev
- Before creating a Pull Request, ensure synchronization:
git pull origin dev git push origin feat/addNewButton
- Create a new branch for development:
- Regular updates from
devhelp avoid merge conflicts. - Using release branches simplifies release management and testing.
- A clear task workflow ensures transparency and predictability in development.
- This document standardizes the workflow, ensuring consistency across the team.
-
main: the single main branch containing stable production-ready code. -
dev: the branch for integrating changes, used by developers for preliminary functionality checks. -
test: the branch for testing changes, used by testers before merging intomain. -
feature/*: short-lived branches for developing new features or fixes.
Note: In the original Trunk Based Development (TBD) methodology, only the
mainbranch and short-lived feature branches are used. The inclusion ofdevandtestbranches in this guide is an adaptation to provide additional flexibility for testing and staging changes.
main
|
|--------> test --------------> main
| ^
| |
|--------> dev ---------------> test
^
|
|---------> feature/*
-
Creating a New Branch:
- For developing a new feature or fix, create a short-lived branch from
dev:git checkout -b feature/yourFeatureName dev
- For developing a new feature or fix, create a short-lived branch from
-
Regular Updates from
dev:- Regularly synchronize your branch with the latest state of
dev:git pull origin dev
- This minimizes the risk of conflicts during merging.
- Regularly synchronize your branch with the latest state of
-
Merging into
dev:- After completing your work, create a Pull Request to the
devbranch for preliminary review.
- After completing your work, create a Pull Request to the
-
Testing in
test:- After successful merging into
dev, test the changes on thetestbranch. Create a Pull Request fromdevtotest:git checkout test git merge dev git push origin test
- After successful merging into
-
Merging into
main:- After successful testing, merge the changes into
main:git checkout main git merge test git push origin main
- After successful testing, merge the changes into
-
Deleting the Branch:
- After merging the Pull Request, delete the short-lived branch:
git branch -d feature/yourFeatureName git push origin --delete feature/yourFeatureName
- After merging the Pull Request, delete the short-lived branch:
-
For Adding New Features:
feat: brief description of the added feature detailed description of changes -
For Fixing Bugs:
fix: brief description of the fix detailed description of changes
-
Task Statuses:
-
backlog: the task is in the backlog. -
todo: the task is ready to start. -
in progress: the task is in progress (a branch is created, e.g.,feature/someNewFunc). -
testing: the task is being tested on thetestbranch. -
rework: the task is returned for rework after failed testing. -
code review: the task is under code review before merging. -
done: the task is completed, and changes are merged intomain.
-
-
Step-by-Step Process:
-
Step 1: Move the task from
backlogtotodo. -
Step 2: Move the task to
in progressand create a branch:git checkout -b feature/someNewFunc dev
-
Step 3: Regularly update your branch:
git pull origin dev
-
Step 4: After completing the work, move the task to
testingand test the changes on thetestbranch. -
Step 5: If testing fails, move the task to
reworkand make the necessary fixes. -
Step 6: After successful testing, create a Pull Request to the
mainbranch and move the task tocode review. -
Step 7: After successful code review, merge the changes into
main, and move the task todone.
-
Step 1: Move the task from
-
Testing on the Feature Branch:
- All changes must be tested on the feature branch before creating a Pull Request.
-
Testing on the
testBranch:- After merging changes into
dev, perform testing on thetestbranch.
- After merging changes into
-
Integration Testing:
- After merging changes into
main, perform integration testing.
- After merging changes into
-
Change Isolation: Developers and testers work in separate branches, not affecting
main. - Flexibility: Allows testing changes before they reach production.
- CI/CD Compatibility: Changes go through multiple verification stages, reducing the risk of production errors.
- Feature Toggles (Flags): Use feature toggles to enable or disable features in production without requiring code changes or deployments.
- Branch by Abstraction: Implement changes incrementally by abstracting new functionality behind interfaces, reducing the need for long-lived branches.
- Continuous Code Review: Encourage frequent and incremental code reviews to maintain code quality and ensure faster feedback loops.
Pros:
-
Clear Branch Structure:
- Suitable for projects with long development cycles.
- Release branches isolate release preparation from main development.
-
Convenient for Large Teams:
- Developers can work on multiple features and releases simultaneously.
-
Quality Control:
- Testing on
testandrelease/*branches reduces the likelihood of production errors.
- Testing on
Cons:
-
Complex Branch Management:
- A large number of branches can complicate the process, especially for small teams.
-
Long Development Cycles:
- Suitable for projects with infrequent releases but may be excessive for frequent updates.
-
Conflict Risk:
- Long-lived branches increase the likelihood of merge conflicts.
Pros:
-
Simple Structure:
- Only
main,dev,test, and short-lived branches are used, simplifying the process.
- Only
-
Fast Integration:
- Changes quickly reach
main, ideal for Continuous Integration/Continuous Deployment (CI/CD).
- Changes quickly reach
-
Conflict Minimization:
- Short-lived branches and regular updates from
devormainreduce conflict risks.
- Short-lived branches and regular updates from
-
Testing Flexibility:
- The presence of
devandtestbranches allows isolating changes for developers and testers.
- The presence of
Cons:
-
Requires Discipline:
- Regular branch updates and frequent merges require strict adherence to processes.
-
Less Release Isolation:
- No dedicated branch for release preparation, which may be inconvenient for large projects.
-
Not Suitable for All Teams:
- May be challenging for teams accustomed to long development cycles.
| Criterion | Git Flow | Trunk Based Development |
|---|---|---|
| Team Size | Large teams | Small and medium teams |
| Release Frequency | Infrequent releases | Frequent releases |
| Project Complexity | Complex projects with long cycles | Simple or fast-evolving projects |
| CI/CD Support | Limited | Excellent |
| Release Isolation | High | Low |
| Branch Management | Complex | Simple |
- Use Git Flow if your project has long development cycles, complex releases, or requires strict release isolation.
- Choose Trunk Based Development if you want to speed up development, release frequently, and actively use CI/CD.
-
backlog→todo:- The task is prioritized and ready to start.
-
todo→in progress:- A branch is created from
dev(e.g.,feat/someNewFunc).
- A branch is created from
-
in progress→testing:- The feature branch is tested locally or in a staging environment.
-
testing→rework:- If testing fails, the task is returned for fixes.
-
testing→code review:- After successful testing, a Pull Request is created to the release branch.
-
code review→pre-deploy:- After approval, the task undergoes smoke testing on the
testbranch.
- After approval, the task undergoes smoke testing on the
-
pre-deploy→done:- After successful testing, changes are merged into
mainanddev.
- After successful testing, changes are merged into
-
Branch Naming: Use clear and consistent branch names (e.g.,
feat/addLogin,hotfix/fixLoginBug). -
Regular Updates: Frequently pull changes from
devto avoid conflicts. - Testing: Test thoroughly on feature branches before merging.
- Release Isolation: Use release branches to isolate changes for specific releases.
- Documentation: Document changes in Pull Requests for better traceability.
-
backlog→todo:- The task is prioritized and ready to start.
-
todo→in progress:- A short-lived branch is created from
dev(e.g.,feature/someNewFunc).
- A short-lived branch is created from
-
in progress→testing:- The feature branch is tested locally or in a staging environment.
-
testing→rework:- If testing fails, the task is returned for fixes.
-
testing→code review:- After successful testing, a Pull Request is created to
dev.
- After successful testing, a Pull Request is created to
-
code review→done:- After approval, changes are merged into
dev, tested ontest, and finally merged intomain.
- After approval, changes are merged into
- Short-Lived Branches: Keep branches short-lived to minimize conflicts.
-
Frequent Merges: Merge changes into
devfrequently to ensure fast feedback. -
Testing Stages: Use
testfor staging changes before merging intomain. - Feature Toggles: Use feature toggles to enable or disable features in production.
- Continuous Integration: Automate testing and integration to maintain code quality.
| Status Transition | Git Flow | Trunk Based Development (TBD) |
|---|---|---|
backlog → todo |
Task is prioritized for release. | Task is prioritized for immediate work. |
todo → in progress |
Branch created from dev. |
Short-lived branch created from dev. |
in progress → testing |
Tested on feature branch. | Tested on feature branch. |
testing → rework |
Fixes applied on feature branch. | Fixes applied on feature branch. |
testing → code review |
PR to release branch. | PR to dev. |
code review → done |
Merged into main and dev. |
Merged into main via test. |
- Use Git Flow for projects with long development cycles and strict release isolation.
- Use TBD for projects with frequent releases and CI/CD pipelines.
- Ensure clear communication and documentation for all task transitions.
- Regularly review and refine workflows to adapt to team needs.
- The described workflow is logical and aligns with the standard Git Flow methodology.
- The use of
release/*branches for isolating release preparation ensures stability inmainanddev. - Task status transitions are well-defined and follow a clear sequence.
-
Complexity: Managing multiple long-lived branches (
main,dev,test,release/*,feat/*,hotfix/*) can become overwhelming for smaller teams. - Merge Conflicts: Long-lived feature branches increase the risk of conflicts, especially if multiple developers work on overlapping areas of the codebase.
- Best suited for larger teams with structured release cycles and dedicated QA/testing teams.
- Requires discipline in branch management and adherence to the workflow.
- The workflow is consistent with the principles of TBD, emphasizing short-lived branches and frequent integration.
- The use of
devandtestbranches provides flexibility for testing and staging changes before merging intomain.
-
Testing Bottleneck: If multiple features are merged into
devsimultaneously, it may create bottlenecks during testing on thetestbranch. - Discipline Required: Developers must frequently merge changes and resolve conflicts promptly to avoid disruptions.
- Ideal for smaller or medium-sized teams with frequent releases and CI/CD pipelines.
- Requires a strong culture of collaboration and continuous integration.
- Both approaches can coexist if the teams work on separate projects or modules with minimal interdependencies.
- Clear communication and documentation are essential to avoid confusion when integrating changes across teams.
- Cross-Team Collaboration: If the two teams need to collaborate on shared code, differences in workflows (e.g., release branches in Git Flow vs. short-lived branches in TBD) may cause friction.
- Tooling and Automation: CI/CD pipelines and testing frameworks must support both workflows to ensure smooth integration.
- Assign Git Flow to a team working on a project with long release cycles and complex dependencies.
- Assign TBD to a team working on a fast-evolving project with frequent releases.
- Establish clear guidelines for integrating changes between the two teams, such as using
mainas the common integration point.
- Use for teams with structured release cycles and a need for strict release isolation.
- Automate testing and deployment for
release/*andtestbranches to reduce manual effort.
- Use for teams with frequent releases and a focus on CI/CD.
- Encourage developers to merge changes into
devfrequently and resolve conflicts promptly.
- Define a shared branching strategy for integrating changes between the two teams.
- Use feature toggles to manage incomplete features when integrating changes from TBD into Git Flow.
- Regularly review the workflows to identify bottlenecks or inefficiencies.
- Gather feedback from both teams to refine the processes and address challenges.
Both approaches are logically sound and can work effectively for their respective use cases. However, successful implementation requires clear communication, strong discipline, and appropriate tooling. With proper planning and coordination, it is feasible to use Git Flow and TBD for two different teams.