Inside Look – Git Flow

Working on small projects, picking up a version control system (VCS) was hardly a must for me. I don’t any project here has ever had more than 4 people working on it at once. Nevertheless, using Git and a well established process can be incredibly useful for even the individual coder. It allows a one (or multiple people) to work on multiple paths of a project without (or at least little) worry of seriously corrupting the source code. Git is known as a decentralized version control system. There is no one golden repository which everyone must work from. In fact, any individual has their own copy of the repository which they can use to track their own local changes as they’re working. There are many ways to use Git to keep on top of a project and I think everyone finds their own style, but I’d like to share what I’ve been using.

My projects consist of two main branches, master and develop. These branches will always exist and will never be removed.

The two main branches.

The two main branches.

Master is considered sacred and only touched if a completely sound production release is ready. Instead, develop contains typically the latest, active, and (reasonably) working code. When a the team has a new feature they want to introduce, they create a branch off of develop. This is called a feature branch. This is worked on until completed and then merged back into develop. Sometimes, merges may happen before a feature is fully completed. Maybe there was a specific change that needed to be present in develop for other feature branches or some bug was found.

A feature branch example

A feature branch example.

In a perfect world, these are all the branches of code you would ever need to care about. There are many corner cases that can occur where you may need to create a hotfix branch to fix a bad release on master, you may have a feature with sub-features being worked on, and many more. For a nice example, here’s a bigger picture of what that may look like.

A full Git Flow example.

A full Git Flow example.

Huge credit goes to Vincent Driessen for these images. You can find his post at http://nvie.com/posts/a-successful-git-branching-model/ which describes the full process. Over a year ago when I was just getting into this Git thing, his post allowed me to finally grasp a good method of using this powerful tool.

Advertisements
Tagged , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: