This document outlines Bayat's official branching strategy: Trunk-Based Development. This model is designed to promote continuous integration, simplify workflows, and enable rapid, high-quality releases across all project types, from web applications and mobile apps to game development and libraries. It replaces the previously used Git Flow model.
- Single Source of Truth: The
mainbranch is the trunk and the single source of truth for the codebase. - Continuous Integration: All developers integrate their work into the
mainbranch frequently. Every commit tomainshould be production-ready. - Short-Lived Branches: Feature development occurs in short-lived branches that are merged into
mainas quickly as possible. - Feature Flags: Incomplete features are merged into
mainbut are hidden behind feature flags to avoid impacting production. - Release from Trunk: Releases are cut directly from the
mainbranch, often by creating a tag.
main: This is the trunk. It must always be in a stable, deployable state. Direct commits tomainare prohibited; all changes must come through Pull Requests.
feature/*: For new features.bugfix/*: For bug fixes.refactor/*: For code improvements.docs/*: For documentation changes.experiment/*: For experiments that might be discarded.
All development branches are short-lived (ideally lasting less than a few days) and are created from the main branch.
- Use lowercase for all branch names.
- Use hyphens to separate words.
- Include ticket/issue numbers when applicable.
- Be descriptive but concise.
Examples:
feature/JIRA-123-user-profile-page
bugfix/login-form-validation
refactor/simplify-database-queries
docs/update-readme
-
Branch Creation:
- Always branch from the latest version of
main. - Command:
git checkout main && git pull && git checkout -b feature/your-feature-name
- Always branch from the latest version of
-
Development:
- Commit frequently with clear, descriptive messages.
- Keep your branch synchronized with
mainby frequently pulling changes frommaininto your feature branch. This helps to avoid large merge conflicts later. - Command:
git pull origin main
-
Pull Request (PR):
- When your changes are complete (and ideally small), open a Pull Request to merge your branch into
main. - The PR should be small, focused, and backed by automated tests.
- If the feature is not yet complete, it must be hidden behind a feature flag.
- When your changes are complete (and ideally small), open a Pull Request to merge your branch into
-
Code Review and Merge:
- The team reviews the PR.
- Once approved and all CI checks are passing, the branch is merged into
mainusing a squash and merge strategy. This keeps themainbranch history clean and linear. - After merging, the feature branch should be deleted.
Releases are simple and are triggered directly from the main branch.
- Decision to Release: When
mainhas the desired set of features and is stable, a release can be made. - Tagging: A new version is created by tagging a commit on the
mainbranch. We use semantic versioning for tags (e.g.,v1.2.3).- Command:
git tag -a v1.2.3 -m "Release version 1.2.3" && git push origin v1.2.3
- Command:
- Deployment: The CI/CD pipeline is triggered by the new tag and deploys the tagged commit to production.
There are no release branches. The main branch is the release branch.
Hotfixes are handled in the same way as any other bug fix. There are no special hotfix branches.
- Create a
bugfix/*branch frommain. - Implement the fix.
- Open a PR, get it reviewed (expedite if necessary), and merge it into
main. - Tag a new patch release from
mainand deploy it.
Feature flags are essential for Trunk-Based Development. They allow us to:
- Merge incomplete features into
mainwithout affecting users. - Decouple deployment from release. A feature can be deployed to production but kept hidden until it's ready to be released.
- Perform A/B testing and canary releases.
- Quickly disable a faulty feature without redeploying.
All new user-facing features should be developed behind a feature flag.
A robust CI/CD pipeline is a prerequisite for Trunk-Based Development.
-
On Feature Branches: For every commit to a feature branch, the CI pipeline should:
- Run linting and static analysis.
- Run all unit and integration tests.
- Build the application.
- (Optional) Deploy to a temporary preview environment.
-
On Merge to
main: When a PR is merged intomain, the pipeline should:- Run all the same checks as on the feature branch.
- (Optional) Run end-to-end tests.
- Publish a new build artifact.
- Deploy to a staging environment for final verification.
-
On Tag: When a new tag is pushed, the pipeline should:
- Deploy the exact build artifact from the tagged commit to production.
Commit message standards remain the same as before. Refer to the Git Commits Conventions for detailed guidelines.
Trunk-Based Development is a modern, streamlined approach that enables teams to move faster and release more frequently and reliably. By adhering to the principles of continuous integration, short-lived branches, and the smart use of feature flags, we can improve our development workflow across all Bayat projects.
| Version | Date | Description |
|---|---|---|
| 2.0.0 | 2025-09-18 | Migrated from Git Flow to Trunk-Based Development |
| 1.0.0 | 2025-03-20 | Initial version (Git Flow) |