Branching Strategy
The overall branching strategy flow is:
- A
developbranch is created frommain - A
releasebranch is created fromdevelop - Feature branches are created from
develop - When a feature is complete it is merged into the
developbranch - When the
releasebranch is done it is merged intodevelopandmain - If an issue in main is detected a
hotfixbranch is created frommain - Once the hotfix is complete it is merged to both
developandmain
Develop and main branches
mainbranch is the main branch where the source code of HEAD always reflects a production-ready state.developbranch is the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release.
Feature branches
Each new feature should reside in its own branch, which can be pushed to the central repository for backup/collaboration. But, instead of branching off of main, feature branches use develop as their parent branch. When a feature is complete, it gets merged back into develop. Features should never interact directly with main.
Release branches
When the develop branch has enough features or a release date is near, a release branch is created from develop. This starts the release cycle, allowing only bug fixes, documentation, and release tasks in this branch. Once ready, it merges into main, is tagged with a version number, and merges back into develop.
Using a release branch allows one team to finalize the release while another works on new features. It clearly defines development phases, making it easy to see when the team is preparing for a specific release.
Hotfix branches
Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on main instead of develop. This is the only branch that should fork directly off of main. As soon as the fix is complete, it should be merged into both main and develop (or the current release branch), and main should be tagged with an updated version number.