Git Branching Model – Setting up Git to manage the Source Code

Git Branching Model

The central repo holds two main branches with an infinite lifetime Master and Dev Branches.

  • Master branch at origin should be familiar to every Git user.
  • Dev branch is the parallel to the master branch. This is also called Integration Branch where any automatic nightly build are build from.

Nightly Vs Production

  • Next release state – Source code of HEAD for the develop branch always reflects for the next release with the last delivered development changes.
  • Product ready state – Source code of HEAD for the main branch always points to production ready state.
git dev and master branches
Git Dev and Master Branches

New Production Release

For new production release, the following are the steps to be performed.

  • Dev branch source code should reach stable point.
  • All the changed should be merged to main branch
  • Tag with a release number.
  • We can use git hook scripts to build and roll out a new production release version and automatically deploy to the production servers.

In order to support development activities between team members and to make the ease for tracking features development, we will create a following types of branches with limited lifetime and these are deleted timely manner once these merged with either develop or main branched.

  • Feature Branches
    • To develop new features for the upcoming or a distant future release.
    • Exists as long as the feature is in development
    • Merged to dev branch once feature implementation is complete
  • Release Branches
    • Support preparation of a new production release
    • Allow for minor bug fixes in this branch
    • At this branch level, we will prepare meta-data for a release (version number, build dates, scripts etc.)
    • At least all the targeted features for this release must be completed and merged into dev branch before creating a new release branch.
    • Exists until release or build is rolled out.
  • Hotfix Branches
    • This branch is created when there is a critical bug in production release
    • Once bug is fixed, bugfix needs to be merged back into master and develop to include this future releases as well.

Type of BranchBranch Off FromMerge Back IntoNaming Convention
Feature Branchdevdevanything except master, dev,
develop, release-*, or hotfix-*
Release Branchdevdev and masterrelease-*
Hotfix Branchmasterdev and masterhotfix-*
Comparison between type of branches with limited lifetime

The complete branching model

git branching model

0 Shares:
Leave a Reply

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

You May Also Like