Git Branching model for Continuous Integration
Best Practices

Git Branching model for Continuous Integration

Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+
Buffer this pagePin on PinterestDigg thisShare on RedditShare on StumbleUponShare on Tumblr

Its always a better to use a version control systems in development. And there are lots of version control systems available in the market, its always not about the tool, its about how we make use of its features to fit our needs. In this post I’ll be talking about branching. Almost all version control systems out there in the market supports branching.

Branching allows development teams to work independently on different features and then merge it to the main / master branch. Merging multiple branches was always a painful task in the earlier days with version control systems like SVN but the version control systems like Git, Mercurial made these tasks simpler.

In recent times the Continuous Integration (CI) and Continuous Delivery (CD) has become more popular and its a very good model when your team is working in an agile model.

Main Branches

  • master
  • development

Initially we will start with development branch. The development branch should be checkout from the master.

$ git checkout -b development master
basic_git_branching
Basic Git Branching

The master branch always contains  the production ready code. The development branch contains the latest development code which may or may not be stable. Once your code in the development branch comes to a stable state you can be merged to master.

Supporting Branches

  • features
  • releases
  • bug fixes
Feature Branch

The feature branches are used to develop new features. These branches must be checked out from development branch and should be merged to development branch.

Create a feature branch,

$ git checkout -b new-feature-1 development

Once the feature is complete you can merge it back to the development branch.

$ git checkout  development
$ git merge --no-ff new-feature-1
# Delete the feature branch
$ git branch -d new-feature-1

The  “--no-ff"  flag will always create a new commit object during merge. This keeps the historical existence of the feature branch.

feature_git_branch
Feature Branch
Release Branches

Release branches are used to make minor bug fixes, release specific meta data updates like version number updates, build dates, etc., The release branch must be checked out from development branch and should be merged to development and master.

Bug Fixes

For critical bug fixes in the production, create a separate branch and make the changes. This branch should be checked out from master and should be merged back to master and development.

git-branching-continuous-integration
Git Branching Continuous Integration

The above image describes the better workflow for continuous integration. It also helps in organising and identifying the individual performances. It also better suits for agile development process.

Share on FacebookTweet about this on TwitterShare on LinkedInShare on Google+
Buffer this pagePin on PinterestDigg thisShare on RedditShare on StumbleUponShare on Tumblr

Leave a Reply

Your email address will not be published. Required fields are marked *