You are currently offline, so some features of this site may not work fully.

Your browser doesn’t support some of the latest CSS features used to build this site.

Read more about my usage of new CSS features.

I promised I’d write this when I overcame my initial apprehension of git-flow…turns out it’s not scary at all.

Git-what?

Git flow (the actual toolset, not the methodology) is:

Git extensions to provide high-level repository operations for Vincent Driessen's branching model. https://github.com/nvie/gitflow

So I’ve used git-flow very little (we have one project at work using it I believe) - and I’ve mostly thought before that as a set of tools git-flow is kind of redundant and that you should probably just have a sensible work flow without it anyway.

Keep reading - I’m about to change my opinion…

In most projects I have a master branch that I deploy to production from, a develop branch that I work on fixes and feature/* branches for specific new tasks.

A screenshot of my repository branches on GitHub
All of the branches on GitHub

My own workflow serves me well for small projects with just me developing or with a couple of friends but even mere minutes after starting to use git-flow properly for this post I already see the benefits!

Git-flow go

The easiest way to install git-flow (on a Mac) is via Homebrew — run:

brew install git-flow

Another simple method is to use cURL:

curl -L -O https://raw.github.com/nvie/gitflow/develop/contrib/gitflow-installer.sh

Then run the installer with bash gitflow-installer.sh.

Concepts

The main concepts behind git-flow that I use are:

  • Keep your master branch clean and ready to deploy to production at any moment
  • Merge complete features/fixes that are ready for release into your develop branch
  • Before a release, a release branch is created to prepare the appropriate features, which is then merged into master for deployment
  • Critical fixes can be made in a hotfix branch and merged back down the stream, to develop / feature branches
  • Other bug fixes addressed in release branches are also merged down

Getting started

To start git-flow run git flow init and follow the instructions for the inital setup, then to create your first feature branch enter:

git flow feature start awesome-feature-name

- which creates and switches to that branch for you, ready to work! Easier than remembering all of the Git commands individually.

A screenshot of my terminal window with git flow, creating a feature branch.

Now just keep working away on your feature and committing as normal.

Getting finished

After a feature is finished, (I had to pick a small feature from my Waffle board to do for this screenshot) just run git flow feature finish awesome-feature-name to:

  • Merge the finished feature into develop branch
  • Remove the now un-needed feature/my-awesome-feature branch
  • Switch to develop, ready for your next action
A screenshot of my terminal window with git flow, finishing a feature branch.

Now this is a pretty basic usage of git-flow so far, but what about releasing and deploying features?

Getting deployed

The last thing we need to do for this post is create a release branch. You can do so as follows:

git flow release start version

When every feature is in the release branch and you’re ready to go, run:

git flow release finish version -m "release note"

which will remove the release branch and merge it into master - which is where you should be deploying from.

A screenshot of my terminal window with git flow, creating and finishing a release branch.

Finally, push master to trigger a deploy - I’ll be doing this in just a few minutes to deploy this blog post!


TL;DR

This post is my brief introduction into using git-flow the set of tools available to help with more advanced, structured workflows.

During the course of writing this post, I actually had to jump out of the flow of things and do a really quick hotfix and get it to live - so if I didn’t before, I immensely appreciate the benefit of git-flow now!

Git-flow ain’t too scary, y’all.

Useful resources