Managing your source code properly is a huge factor in the success or failure of most software development projects. Many developers are already familiar with Git, a popular source code control technology.

Today, I want to share with you some thoughts on making Git much more useful. It’s called Git Flow, and it solves those real life problems that software developers run into when managing their source code.

What is Git Flow?

Git Flow enhances Git’s value by introducing processes and workflows that make it easier to implement and take advantage of different stages of your code. It was first created by Vincent Driessen in a blog post in 2010 and proved wildly popular with many Git users.

So what does it do? Git Flow is a technique to leverage Git’s core features, allowing more flexibility in certain circumstances. Specifically, Git Flow enhances your source code management options for key product lifecycle events such as:

  • Adding new features
  • Fixing bugs
  • Preparing for release
  • Deploying to production
  • Applying hotfixes

Why Do You Need Git Flow?

Git is a pretty powerful tool by itself with a lot of great features. So why do I recommend adding Git Flow to your software development arsenal? Here are some of the additional benefits Git Flow provides:

  • Separates your source code’s current shipping state from your next release shippable state. This is crucial for Scrum development projects where code is completed in short, shippable increments.
  • Allows more flexibility in deciding when to release. You can release the latest shippable product code at any time, without causing any problems in your source code management.
  • Protects the next release from incomplete features. By using a separate branch for each feature, Git Flow makes it easier to keep the code for incomplete features separate, saving them for future release.
  • Allows surgical hotfixes that can be pushed into production without disrupting the source code for your next release.

The 5 Branches of Git Flow

The core function of Git is to manage and protect your source code in production. We’ll call this the “Master” branch.

Git Flow then introduces four other branches, starting with the “Develop” branch.

The Develop branch provides brand new opportunities for your software development team. It includes code that has been code reviewed and tested. It enables the “shippable product increments” that are necessary for your Scrum-based projects. And it lets you ship at any time, even if there are incomplete features you don’t want to include.

Next are “Feature” branches that can be used to separate your coding tasks in Git Flow.

The Feature branch is merged from Develop and each represents a single feature (user story) or bug fix. These keep a variety of works-in-progress separate from your main development state. This, in turn, permits you to ship at any time. Individual features are simply merged back into the Develop branch when they’re ready.

The fourth branch is a “Release” branch to make the process of releasing code into production much easier.

The Release branch is created just before a release. It allows you to address any minor tweaks and bug fixes during the release while not locking your team out of working on new stuff. It also allows you to update version numbers as well as differentiate them from marketing versions. When the release is finished, it gets merged back into the Master, or production, branch, as well as the Develop branch, to ensure any adjustments made during the final testing process will be carried forward to the next release.

Finally, there is a “Hotfix” branch for correcting high priority problems in production.

The Hotfix branch is for bugs that require immediate fixes when you can’t wait for a new release. Created from the Master branch, this lets you code, test, and then simultaneously merge the fix into both the Master and Development branches (preventing the same bug from reappearing in your next release).

To review, the five branches enabled by Git Flow are:

  • The Master Branch
  • The Develop Branch
  • Feature Branches
  • Release Branches
  • Hotfix Branches

Adopting Git Flow adds powerful new functionality into your process.

The Git Flow Story Lifecycle

So what exactly happens in Git Flow when your development team writes the code for a user story?

Here’s how it works:

  1. A feature branch is created from the develop branch.
  2. The engineers write the code and the unit tests for it.
  3. The code from the feature branch is tested in the QA environment.
  4. Any bugs are then fixed, still within the feature branch.
  5. A pull request is created to move the code from the feature to the develop branch.
  6. A code review is performed and any necessary edits made.
  7. The pull request is closed and the feature branch is merged to develop.
  8. The product owner reviews the new feature in the develop branch in a separate environment dedicated to that branch.

Tools That Make Git Flow Easy

In the Improve your Development Team with Git Flow webinar, I cover several additional topics, discussing Git Flow in a lot more detail. One of the topics I share is a list of the tools we actually use at Ascendle to manage our source code with Git Flow. If you’d like to learn more about this important topic, or find out which tools we use and why, please view our free webinar now.

Share This Article