GitFlow is a git branching model created to solve a problem of changes management on the projects that have few or more collaborators. The GitFlow model isolates development branches from production to simplify parallel development and hotfixing.
Features Development and Release Management in GitFlow
Following the model, we keep the master
branch for production and create a
staging
branch to contain pre-release work. New features should have their
branches. Feature branches must be created from the staging branch and merged
back when the feature is finished. When the staging branch contains a major
version of the project, it has to be promoted to the master branch and new
features become available on production.
Hotfixes in GitFlow
Hotfixes are applied on child branches of the master branch. Hotfix branches are merged back to the master branch omitting staging. Then the master branch is synchronized with the staging branch afterward.
GitFlow Feature Development Example
At first glance, the GitFlow concept may look complicated. Let’s see how it works for an online shop project. According to the GitFlow model, the online shop development and maintaining flow looks like:
- The latest version of the project has two identical branches:
master
andstaging
; - You are requested to adjust existing product feed filters and add few more;
- The work should be done in a new branch created from the staging branch. Call
it
shop-feed-filters
; - When you finish development of the feature, merge the
shop-feed-filters
branch back into staging; - The new feature is ready for testing on
staging
and when it’s verified, staging can be merged to production.
GitFlow Hotfix Example
Suddenly you may find a critical bug on your production. You need to fix it immediately and going through feature development flow isn’t an option. Following the instructions will allow you to fix the issue and help you to avoid passing it through the feature development flow:
- Create a
hotfix-1
branch from themaster
; - Apply a fix in the branch and merge to the production;
- That’s it! The only thing you still need to do is performing synchronization
of the production and staging branches. Switch to the
staging
and pull themaster
.