Git is the most commonly used version control system today. A Git workflow is recommendation for how to use Git to accomplish work in a consistent and productive manner. Git workflows encourage developers and DevOps teams to leverage Git effectively and consistently. Git offers a lot of flexibility in how users manage changes. Given Git's focus on flexibility, there is no standardized process on how to interact with Git.
Working of Git Flow
Develop and Master Branches
Instead of a single master branch, Git Flow uses two branches to record the history of the project. It is based on two main branches with infinite lifetime namely master and develop.
Master Branch: The master branch contains the production code and stores the official release history.
Develop Branch: The develop branch contains pre-production code and serves as an integration branch for features.
Each new feature should reside in its branch, which can be pushed to the central repository for backup/collaboration. Feature branches use the latest develop as their parent branch. When a feature is complete, it gets merged back into develop. Features should never interact directly with the master branch.
Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are necessary to act immediately upon an undesired status of master. Hotfix branches are a lot like release branches and feature branches except they’re based on master instead of develop. This is the only branch that should fork directly off of master. As soon as the fix is complete, it should be merged into both master and develop (or the current release branch), and the master branch should be tagged with an updated version number.
Advantages of Git Flow
- Now let’s talk summarize the major advantages provided by Git flow:
- Ensures a clean state of branches at any given moment in the life cycle of a project
- The naming convention of branches follows a systematic pattern making it easier to comprehend
- Has extensions and support on most used git tools
- Ideal in case of maintaining multiple versions in production
- Great for a release-based software workflow.
- Offers a dedicated channel for hotfixes to production.
Disadvantages of Git Flow
- Well nothing is ideal, so Git Flow holds some disadvantage as well like:
- Git history becomes unreadable
- The master/develop branch split is considered redundant and makes the Continuous Delivery/Integration harder
- Not recommended in case of maintaining a single version in production