Git, Git Flow and Git Branching Model
We follow a branching model based on the Git Flow model. This adaptation allows us to tailor the branching strategy to our specific workflow. In this guide, we will explore our Git Flow branching model and its key concepts.
Branches
Main Branches
- Main Branch: Represents stable, production-ready code.
- Develop Branch: Integration branch for ongoing development, mainly containing stable code. In the beginning of a project, only the
develop
branch is used to speed up development.
Supporting Branches
-
Feature Branches: Created from
develop
for developing new features or enhancements. Merged back intodevelop
or arelease
branch. -
Release Branches: Created from
develop
to finalize testing and preparation before deployment. Feature branches are merged into the release branch. Final testing and bug fixes are done here. -
Hotfix Branches: Created from
main
to address critical bugs in the production code. Fixes are merged back intomain
anddevelop
.
Workflow for “On-Going” Development
- Create a
feature
branch fromdevelop
. - Develop the feature and make focused commits.
- Merge the feature branch into
develop
or arelease
branch. - Create a
release
branch fromdevelop
to finalize testing and preparation. - Merge tested feature branches into the release branch.
- Perform final testing, bug fixing, and adjustments in the release branch.
- Merge the release branch into
main
anddevelop
, adding a version tag tomain
. - For critical bugs, create a
hotfix
branch frommain
. - Apply fixes in the hotfix branch and merge them back into
main
anddevelop
.
Using the Gitflow CLI
To simplify the adoption of the Git Flow model, you can use the Gitflow CLI. This command-line tool provides commands like git flow init
, git flow feature start
, git flow release start
, and git flow hotfix start
to initialize and manage branches seamlessly.
To install the Gitflow CLI, follow the instructions provided by the repo.