Important
In the following, X, Y and Z refer to MAJOR, MINOR and PATCH of Semantic Versioning.
Git Flow is a branching strategy that defines dedicated branches for features, releases, and hotfixes, built around long-lived main and develop branches. It’s well suited for projects with long or complex release cycles, or when teams need an unstable shared branch for ongoing development.
These are the 5 types of branches used in this strategy:
| Name | Type | Purpose |
|---|---|---|
main |
Permanent | Represents the production-ready state; all releases originate here. |
develop |
Permanent | The integration branch for ongoing development; features are merged here. |
feature/* |
Temporary | Branches for developing new features, branched off from develop. |
release/X.Y.Z |
Temporary | Branches for preparing a new production release, branched off from develop. |
hotfix/* |
Temporary | Branches for critical fixes to the production version, branched off from main. |
- Create a branch from
develop. - Work on the feature.
- Rebase on-top of
develop. - Push changes and open a PR. Ask for a review.
- Merge branch to
developwith a merge commit.
- Create a branch named
release/X.Y.Zfromdevelop. - Perform all steps needed to make the release.
- Push changes and open a PR. Ask for a review.
- Merge
release/X.Y.Ztomainand also todevelop. - Create a release from
main. The tag should be namedvX.Y.Z.
- Create a branch named
hotfix/your-branch-namefrommain. - Work on the fix. Perform steps needed to make the release.
- Push changes and open a PR. Ask for a review.
- Merge
hotfix/your-branch-nametomainand also todevelop. - Create a release from
main. The tag should be namedvX.Y.Z.