Reading:
What Is Gitflow and Why Should You Use It?

Image

What Is Gitflow and Why Should You Use It?

For those who are not generally familiar with Git, Gitflow or version control systems (VCSs), these are comprehensive technical solutions to manage changes in our source repositories. Source repositories can be thought of as databases of source code that we can draw from.

Version control systems are indispensable to modern development. VCSs enable programmers to access, modify, and launch source code files from a single centralised location.

More importantly, however, they are the starting point for understanding how Git and the Gitflow workflow function.

Why is Git Used?

In modern development teams — among other VCSs such as Mercurial, SVN and CVS — Git has become a de facto standard. It enables us to work collectively with the source code and other artefacts, then push our changes back to the team repository as soon as we are done with our work. However, as effective as Git is, it’s not without some unique challenges.

For example, without the appropriate workflow in place, developers may find themselves in an infinite loop of impending difficulties, struggling to fix code defects each time that the production code is changed. This is where Gitflow comes in…

What is Gitflow

What is Gitflow?

To solve Git-related problems, developer Vincent Driessen created the Gitflow branching model, a particularly useful framework for streamlining collaboration and scaling teams.

Essentially, Gitflow gives us a set of rules for how to work with individual Git branches by assigning specific roles and defining how they interact. Because it was developed with the project release in mind, it varies widely from project to project and should ideally mirror your own development needs.

Gitflow’s main distinguishing factor is that, instead of making use of a single master branch, it uses multiple branches running in parallel to record your project’s unique history.

While the ‘master branch’ is fully tested and should at all times be production-ready, the ‘develop branch’ is an integration branch for the project’s features. The latter is also where all tests should be performed.

To understand this more clearly, take a look at our Gitflow overview below.

An Overview of the Gitflow Strategy

  1. A develop branch is created from the master branch
  2. A release branch is created from the develop branch
  3. Multiple feature branches are created from the develop branch
  4. Completed features are merged into the develop branch
  5. Finished release branches are merged into the develop and then master branches
  6. When issues are found in the master branch, a hotfix branch is then created from it

Gitflow as a Branching Strategy for Agile

If you’re feeling confused, consider Gitflow in an Agile context.

For instance, once we’ve completed all of our user stories, each feature branch may correspond to a unique software requirement. This way, the entire development team can deal with individual tasks while employing multiple repositories to simultaneously tackle different parts of the code. This greatly speeds up development, and serves to coordinate our work smoothly.

Another way in which Gitflow integrates with Agile fantastically is in the area of code reviews. With the help of pull requests, team members can automatically be notified that a particular branch is ready for quality checks.

Note that taking too long to merge feature branches may impair a team’s ability to quickly iterate, so it is worth taking the time to decompose user stories and ensure that all feature branches are made up of smaller project tasks.

Is Gitflow Still Relevant?

Recent years have not exactly been kind to Gitflow. Despite still being a relevant and effective workflow which is compatible with modern development practices, a few drawbacks have come to light.

Despite the challenges posed by these drawbacks, Gitflow remains a robust and valid workflow option, one which is more than capable of facilitating efficient development, and which is particularly well suited to projects with a scheduled release cycle. It may have fallen out of favour amongst some teams, but Gitflow is far from dead.

Drawbacks of Gitflow in a CI/CD Environment

Some of the challenges faced by users of Gitflow relate specifically to development in the context of Continuous Integration and Continuous Deployment (CI/CD) environments…

Complex Branching Model

Gitflow’s reliance on multiple long-lived branches (develop, feature, release, hotfix, etc.) can complicate automated build and deployment processes. Each branch may require its own pipeline, increasing maintenance efforts and the potential for errors. CI functions best when using simpler branch structures to streamline merging and deployment processes.

Integration Delays

In Gitflow, features are often developed in isolation and merged into the develop branch only when complete. This can lead to large, infrequent merges that are more challenging to integrate and test. CI/CD best practices favour smaller, more frequent commits to the main branch to facilitate continuous testing and integration, reducing the risk of merge conflicts and integration issues​.

Increased Overhead

Managing multiple branches means more overhead in terms of branch synchronisation and ensuring all branches are up-to-date with the latest changes from the main and develop branches. This can slow down the overall development process and introduce additional complexity in tracking and merging changes across various branches.

Delayed Feedback

The delay in merging feature branches to the develop branch means that receiving feedback on code changes is not immediate. CI/CD pipelines are designed to provide quick feedback on code changes, enabling the faster detection and resolution of issues. With Gitflow, this feedback loop is often slower, as changes are not continuously integrated and tested.

Resource Intensive

Each branch in Gitflow may need its own set of resources for building, testing, and deploying, which can be resource-intensive. This can lead to inefficiencies and increased costs, especially in environments where resources are limited or need to be optimised for faster turnaround.

Adjusting Gitflow For Modern Development

The challenges posed when using Gitflow in a CI/CD environment are evident, but there are ways to mitigate these. Some teams have adopted modified workflows and brought Gitflow into the modern world…

Feature Toggles

Implementing feature toggles (a technique used to enable or disable features in a software application without deploying new code) allows features to be integrated into the main branch more frequently without being fully exposed to users, enabling continuous integration and testing while development is ongoing. This practice helps with both incremental releases and controlled rollouts.

Trunk-Based Development

Many teams are moving towards trunk-based development, which is now considered best practice for modern software development and DevOps. Trunk-based development simplifies the workflow by encouraging frequent integrations into a single trunk or mainline, reducing the overhead associated with managing the multiple long-lived branches which are inherent to Gitflow. Teams can incorporate aspects of trunk-based development into the Gitflow process, where developers frequently commit to the main branch, complemented by short-lived feature branches that are merged back quickly.

Enhanced Tool Support

Utilising advanced CI/CD tools that support complex branching models can help to manage the intricacies of Gitflow. Platforms like AWS CodePipeline have introduced new features to support more complex branching strategies, including those used in Gitflow. This includes branch-based development and support for monorepos, allowing teams to better manage their pipelines with tailored execution modes and triggers.

Are You Looking For a Technology Partner?

Is Gitflow for You?

The Gitflow workflow is an extremely important part of the software development process, as it allows us to make safe changes to projects whilst supporting a reliable codebase. Gitflow remains relevant and versatile, making it a great fit for a wide range of different development projects.

In the end, Gitflow is yet another tool in SPG’s expansive development arsenal. With its help, we can efficiently coordinate our prolific software developers, work on various project objectives including new functions, experimental features, research and QA/QC procedures, and fix defects in code. Thanks to Gitflow, we can accomplish all of this whilst working in parallel, and without affecting one another’s code.

Related Stories

How does AI work - 2880x1500
August 20, 2021

How Does Artificial Intelligence Work?

Gatsby vs Next
June 25, 2024

The Great Debate: Gatsby vs. Next.js

Gatsby or Next.js: Choosing the perfect framework for your web development. Dive into this comprehensive comparison and select the best fit for your needs.

Is the Desktop Application Dead
April 3, 2019

Is the Desktop Application Dead?