Improve your GIT workflow with Git Flow

Git-Flow is a development workflow for keeping your branching consistent among your team. In this article I will explain the different branches and how to go about implementing this process into your workflow.

Branches

First before we get started, let’s go over a quick overview of what the naming conventions are for our branching. We have 2 primary branches.

Master Branch

Develop Branch

Our master branch can be looked at as our currently released branch, or what you’d find in production. The develop branch on the other hand would be our integration branch.

Apart from the primary 2 branches, we also have 3 others for maintenance, new features, and release hardening.

Feature Branch

Hotfix Branch

Release Branch

Master Branch

The best way to get started with anything is by doing. So let’s get into some examples and work our way through using this within an actual code base.

The first thing we’ll want to do is it start our git project. Within your project’s directory we’ll run the following.

Keep in mind that you will never be making changes directly on the master or develop branches. We’re only just setting up our project which is why I setup this initial commit on our master branch.

In the above example, I created a repository on GitHub, which is where we’ll store our data remotely.

Develop Branch

Next step is to really setup our develop branch, where we’ll be able to integrate our features. We also want to setup this branch so that it is also remotely tracked. We’ll do this by issuing the following commands within our terminal.

git branch develop
git push origin develop

Feature Branches

So now let’s create our first feature. Really every new thing that you do will be a feature, unless you’re having to quickly fix something in your production, which in that case it would be a hotfix.

Let’s say we want to create a new file for lipsum.md, which contains some lorem ipsum text in markdown format.

After we merged the feature, we then went ahead and deleted that branch as it was no longer needed.

Release Branches

Next let’s set up our release branch for our changes. Release branches are typically prefixed with either release/ or release- followed by the version number. This essentially creates a frozen version of the develop branch, this way you can work on hardening the release before merging it into master.

Let’s look at how we would setup our release branch, merge any changes made for our release, and then merge it into master. This is similar to our feature branches, but instead dedicated to polishing up anything we need prior to merging into master.

And that’s all there really is to it. Getting yourself and your team in the habit of following some sort of convention, even if its not this one will improve your development workflow greatly for not only yourself but your team as well.

Tags

About This Blog

I'm writing this blog in order to share what I'm learning with the world. Since you learn best by teaching others and writing things down, I figured this would be the best way to really tackle any new technologies I plan on learning. I hope this blog will help you as much as it will benefit me.