I promised I’d write this when I overcame my initial apprehension of git-flow…turns out it’s not scary at all.
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.
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!
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
The main concepts behind git-flow that I use are:
- Keep your
masterbranch clean and ready to deploy to production at any moment
- Merge complete features/fixes that are ready for release into your
- Before a release, a
releasebranch is created to prepare the appropriate features, which is then merged into
- Critical fixes can be made in a
hotfixbranch and merged back down the stream, to
- Other bug fixes addressed in
releasebranches are also merged down
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.
Now just keep working away on your feature and committing as normal.
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
- Remove the now un-needed
- Switch to develop, ready for your next action
Now this is a pretty basic usage of git-flow so far, but what about releasing and deploying features?
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.
master to trigger a deploy - I’ll be doing this in just a few minutes to deploy this blog post!