7. Introduction to GitFlow

What is GitFlow?

GitFlow is a branching model for Git, introduced by Vincent Driessen in a 2010 blog post. It provides a structured and standardized way to manage features, releases, and hotfixes in a project. GitFlow is particularly useful for projects that have a scheduled release cycle.

NOTE Before using GitFlow, consider the 2020 update of Vincent's blog post:

This model was conceived in 2010, now more than 10 years ago ... During those 10 years, Git itself has taken the world by a storm, and the most popular type of software that is being developed with Git is shifting more towards web apps. Web apps are typically continuously delivered, not rolled back, and you don't have to support multiple versions of the software running in the wild. This is not the class of software that I had in mind when I wrote the blog post 10 years ago. If your team is doing continuous delivery of software, I would suggest to adopt a much simpler workflow (like GitHub flow) instead.

The GitFlow model defines specific types of branches for different purposes:

  1. Master Branch: This branch contains the official release history. It's where versions are tagged.

  2. Develop Branch: This is the main development branch where the latest changes reside. Once the code in this branch reaches a stable point and is ready for release, it gets merged into the master branch.

  3. Feature Branches: These branches are used to develop new features. They branch off from the develop branch and merge back into it once the feature is complete.

  4. Release Branches: When it's time to prepare for a new release, a release branch is created off the develop branch. This branch is for final bug fixes and preparation steps for the release. Once ready, it gets merged into both the master (and tagged) and the develop branches.

  5. Hotfix Branches: If there's a critical issue in a production release, a hotfix branch is created off the master branch. Once the fix is complete, it's merged back into both the master and the develop branches.

Why use GitFlow?

  1. Structured Development: GitFlow provides a clear structure for managing features, releases, and hotfixes. This makes the development process more organized and reduces the chances of conflicts.

  2. Parallel Development: With clear branch types, multiple features or fixes can be developed in parallel without interfering with each other.

  3. Stable Releases: By separating feature development from release preparation, GitFlow ensures that the master branch always contains stable code, ready for production.

  4. Clear Release Management: The process of preparing for a release (like final testing, documentation, and other release-specific tasks) is isolated in its own branch, making the release process more straightforward and less error-prone.

  5. Quick Hotfixes: Critical issues in production can be addressed quickly with hotfix branches, ensuring minimal disruption to ongoing feature development.

  6. Collaboration and Scale: GitFlow provides a standardized workflow, making it easier for teams to collaborate, especially as the team size grows.

  7. History Readability: The commit history becomes more readable and organized, making it easier to track the progress of features, releases, and fixes.

While GitFlow offers many advantages, it might not be suitable for every project. Some teams prefer simpler workflows, especially for smaller projects or projects with continuous deployment. As with any tool or methodology, it's essential to evaluate if GitFlow aligns with the project's needs and the team's preferences.

Last updated