A continuous deployment GIT branching model

Author: Ben B. Ben B | 4/25/19

We’ve used multiple other branching models with some success, including the successful branching model but we found a better way for teams who need to deploy continuously.

Benefits of the continuous deployment branching model:

  • Allow all features from multiple team members to work their way to production simultaneously and continuously as they’re completed
  • Minimize the possibility of a feature becoming a blocker for other team members, features, or releases
  • Prevent unproven code from ever accidentally or maliciously getting to the production server and from being unknowingly propagated to other features
  • Allow multiple features to be tested on a QA server (or staging server) at the same time while allowing for any changes found to be corrupt to be wiped from all environments quickly
  • Give team leaders more visibility and control over how and when changes move to production
  • Improve the clarity of merge conflict resolutions and decrease the likelihood of code code loss
  • Make it easier to start, stop, and re-start new features.

Two Deadly Serious Rules

Ok, they’re not deadly except to team mojo, but here are two rules that you should never forget:

  1. Never merge the develop, qa, or staging branch into any other branch, these branches are always assumed to be corrupt because they’re used to test all features that can become corrupt.
  2. Always branch new features off the master branch (e.g. git checkout -b INSERT_FEATURE_BRANCH_NAME) and keep them up to date by merging in master often.

Branching Summary

First, branch your feature off of master. Make your code changes on your feature branch. Create a pull request into develop. If there is a conflict, remember that you’re conflicting with another feature branch, not develop. Send a link to your pull request to your developer lead for a code and user review. The develop branch is used to test changes on a QA server and can be corrupted and/or thrown away at any time (hence one of the deadly rules above). Once the quality of your feature is assured, we merge it with master and deploy it to the production server.

Prerequisites

  1. You’ll need to make sure you have Git installed on your terminal
  2. Then, clone your code locally (e.g. git clone git@github.com:vuejs/vue.git .)
  3. You’ll start with a master branch and create a develop branch off master.

Branching Steps

Let’s imagine you’ve been assigned issue #999, a bug squashing change requested by a customer.

  1. You’ll need a new branch to keep all your changes together, we call this a feature branch.
  2. Always branch features off the master branch (e.g. git checkout master; git checkout -b 999-bug-squish;).
    • Note the issue number prefix (e.g. 999) on the branch name helps connects your feature branch to the change request.
    • In a perfect world, each issue should have only one branch to make it easy to move your changes through testing to production.
  3. Make your changes on your feature branch and commit them.
    • Pro tip: draw a clear connection between your changes and the issue that requested them by including the issue number in the commit message (e.g. git commit -m '#999 squashed some bugs'). Your team will love you for this.
    • Pro tip: before committing, run git diff to make sure you’re not committing unnecessary changes.
  4. Merge master back into your feature often to make sure it is up-to-date (e.g. git checkout 999-bug-squish; git pull origin master;).
  5. Push your changes back to the origin (e.g. git push origin 999-bug-squish).
  6. Create a pull request (PR) into develop
    • Remember, only proven code makes it to master and it must be proven on the corruptible develop.
    • Pro tip: grab a link to the original issue #999 and include it in the pull request to make sure everything is interconnected.
    • Pro tip: if your changes affect what the user sees (i.e. the view), include a GIF of the new view to make it easier for the reviewer to review.
  7. If your pull request has a conflict, don’t break one of the deadly rules…
    • Remember, your conflict is not with develop, but with another feature merged into develop ahead of yours.
    • Pro tip: first, try merging in the latest from master. The conflicting feature may already be merged into master and syncing your branch could save you a lot of time.
    • If merging in master doesn’t help…
      • Find the third party branch that conflicts with yours and reach out to your lead developer to make a decision whether you should make your code dependent on that branch.
      • Pro tip: find the conflicting branch by using the Blame/Annotate feature of Github/Bitbucket. This is where good commit messages from step #3 can come in handy.
      • Pro tip: if you do make your branch dependent on another feature branch by merging it into yours, note this dependency on the original issue #999.
    • IMPORTANT: the most common mistake when resolving a merge conflict is to delete another developer’s code. You need to be thoughtful about why the conflicting changes were made and double check with the other developer before deleting anything.
  8. One last thing before you submit your pull request for review, do a mock review yourself.
    • Both Github & Bitbucket provide the ability to review and comment on your pull requests. Make sure all your changes are needed and wanted, use comments to explain unusual looking code, make any last minute re-factoring.
  9. Submit for review by comment on the original issue #999 and include a link to the pull request
    • Pro tip: if the changes require special “steps to go live” or unusual “steps to review”, make sure to include those as well when you submit for review.
  10. Your feature branch’s code changes are then reviewed, merged into develop, and deployed to the QA server for further testing by the customer.
  11. Once approved to production, your branch is merged into master and deployed to the production server.
  12. Whenever master changes, you’ll need to merge it back into develop to keep develop up-to-date
    • If master ever has a conflict with develop delete the develop branch and create it again as a copy of master

About The Author

Ben currently works as a senior developer and technical business consultant outside of Boulder, Colorado.

More about this author

About Buink

Buink Web Development is a development shop founded in 2009 by Ben Buie. For years, Ben built and modified web assets for clients in Utah. In 2011, he moved the company to Colorado and in 2015 he started taking on new clients full-time.

Buink’s Core Values:

  • Cost effective technology (with business strategy in mind)
  • Eloquent, maintainable code
  • Responsive and transparent communication

Read more about Buink

Seth Lofgreen
Seth L.
21:36 29 Jun 19
Ben and team are incredible to work with. They are reliable and proficient. I'd highly recommend hiring them for web development work. SethVOLTAGE
Craig Adams
Craig A.
20:50 18 Jun 19
It was a pleasure to work with Ben and his team. It is rare to find such attention to high standards of coding and devops.
Lexi Steele
Lexi S.
15:36 18 Jun 19
Grateful to have Ben and his team as such a capable, reliable partner for completing client work!
Tom Showalter
Tom S.
13:18 14 Jun 19
I reached out to Buink after finding Ben’s name in a local developer/consultant listing in 2017, and I have to say, it has been an absolute pleasure to work with Buink. Ben consistently understands not just the development task laid in front of him but the business application behind the task. I’ve never felt more comfortable with a development team than I do with Buink. I truly feel Ben and his team are integral partners in the success of my business.read more
Craig Scribner
Craig S.
22:01 13 Jun 19
Buink saved my company's bacon at a very critical moment during my company's evolution. With almost no warning we had found ourselves stranded without any dev support, even though we had hundreds of users from big brands every day logging into our application and relying on things to keep working. We couldn't afford to have system failures, and I was amazed at—and will be forever grateful for—the way the Buink team stepped in and calmly assumed control of the craft. We and our clients were safe in their expert hands from that moment forward. I whole-heartedly recommend the quality of their work and the dedicated and ethical leadership they continually provide.read more
Marilyn Ference
Marilyn F.
22:47 13 May 19
I could not recommend Buink Web Development more highly. Ben and his team have recently developed a budgeting app for me (both web and IOS). I have had the opportunity of working with them for over a year and I am extremely happy with the results. I would say that the biggest plus for me is that I trust Ben completely. From the very first, Ben has helped me make decisions that were in the best interest of my company. I have never felt like he is taking advantage of me. Ben does his best to keep the whole process very open and upfront. I have really appreciated that.I tell people all the time that I love my developers. And I do. I'm very happy that I chose to use Buink to develop my apps. It was the best business decision I could have made.If you are looking for someone to develop a website or app, I strongly suggest choosing Buink Web Development. They are fantastic!Marilyn Ference, President, Defend Your Money, LLCread more
James Landon Buie
James Landon B.
01:33 28 Aug 18
Great company to help with all your web design needs!
Next Reviews

Connect with Buink

Connect with Buink via email, send us a message, or subscribe to our blog.