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.
Initially we will start with development branch. The development branch should be checkout from the master.
$ git checkout -b development master
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.
- bug fixes
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
--no-ff" flag will always create a new commit object during merge. This keeps the historical existence of the feature branch.
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.
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.
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.