Oct 22, 2012 by Blake Lucchesi

Git Workflow: Branches

Git has some pretty great features that help improve the product development lifecycle. Today I’d like to share how I use branches to make sure that our product releases don’t miss a beat.

One of single the greatest features of working with Git is its ability to easily create and re-merge branches. During the product development lifecycle things can change quickly. A new feature that you are working on can sometimes become a lower priority, meaning other work must be done and launched before your current work is complete. Because of this, it’s always a great idea to create a new branch for each specific task you are trying to accomplish.

With Git you by default have a ‘master’ branch, and if you are coming from a system like subversion you probably just make all your commits to this branch and get on with it. What I recommend however, is only committing code to the master branch if it’s ready to be deployed onto your live website. By doing this you ensure that at any given time you can easily pick and choose what new code (read: branch) you want to release next.

A Friendly Example

10:00 A.M. - You just got out of your scrum meeting being told that changing the payment processor for your e-commerce site is of upmost importance. Alrighty then, and away you go, writing a new driver class to hook up the API calls.

11:30 A.M. - ZOMG!!! “The link to our twitter page is incorrect!”, screams the marketing manager. “We must update the site immediately!”.

Imagine if you had made a few commits to your payment code (all good developers check-point their progress along the way of course), rendering the site unusable, you certainly couldn’t just change the twitter link and deploy.

Well, if you had begun your payment processing work on a new branch you would easily be able to go back to your master branch, make that quick commit to fix the twitter url, and launch the update in mere nano-seconds. Then you could re-checkout your payment processing branch and get back to real business.

Tutorials on branching and merging



comments powered by Disqus