What is Your Branching Model?
Join the DZone community and get the full member experience.Join For Free
note: at no point are we asking about local branching (on your local workstation with git, etc). this is all about branching on the remote repository. that is if your company has one, and isn’t completely distributed, with no central repo.
teams develop on their own branches, and release from them. the then merge back to ‘mainline’ after the release. many developers co-exist on one branch that can last for months, and that’s how major projects are separated. some branches can be shorter in time than others. sometimes one ‘in-flight’ branch receives interim merges from another in-flight one, despite the intention to merge from mainline exclusively when it’s been updated (after release).
ibm /rational’s clearcase really promoted this from 1998 through 2008. nobody ever got fired for buying ibm .
project teams develops on their own branch and release from there when complete. following releases (for separate projects on the same codebase) are on a branch from taken from the one before. the ‘downstream’ team merges as frequently as they can from the ‘upstream’ branch. it’s a way of handling concurrent development of consecutive releases, but there’s a considerable cost of merge and an even bigger cost of un-merge (of you change the order of major releases).
i’ve only ever seen this once, so i don’t know how prevalent it is. i advised a change to trunk based development, and that paid off shortly after.
all project teams develop on a single trunk. branches happen for releases only (only if a tag was not enough), with cherry-picks to the release branch for defect-fixes.
teams probably use feature toggles , and branch by abstraction too in order to fit that concurrent development of consecutive releases goal.
if you didn’t know already i greatly favor this one in the enterprise.
i prefer that production defects are reproduced on the trunk, and merged to the release branch, but there are many that disagree.
perforce from the middle 90’s and subversion from 2001 promoted a trunk model, although neither preclude other branching models. google have the world biggest trunk-based-development setup, although some teams there are going to say they are closer to continuous deployment (below). facebook are here too.
short lived feature branches
allegedly short lived – there’s a risk of the feature branches morphing into the ‘mainline’ prophesy (above).
all developers make their own feature branches on the remote, work there, and merge back to master after a couple of days “tops”, when they have finished. they then delete the feature branch. this is not unlike doing the same practice on your local-workstation (local branches as git promotes), but when they are pushed up the canonical repo, there’s a potential for sharing, and indeed help completing the feature. you could even hook up ci to those short-lived branches automatically to guard temporary the value they represent.
commits can go all the way to production from one trunk/master, if the automated build says the commit was good. it’s the turbo-switch for tbd , where no humans can hold up a release by taking their sweet time testing it and giving a belated seal of approval. github, etsy, netflix (and many more startups) are all here.
subversion noise on branching
when subversion came out it was suggested that “lightweight branching” was one of the benefits over cvs . when git came out it was suggested that “lightweight branching” was the benefit over subversion. who was right? i think the subversion branch-creation process is quite noisy – it marks every line as an add, when (versus the trunk) it was not like that. in the diagrams above, i’ve used c in a square to denote a commit, and made the size of the square the size of the commit (implies complexity/noise). really for subversion there’s a commit that’s sizable that comes with branch-creation and worth it’s own visualization, even in the tbd model that i prefer:
git and perforce (as you make a branch) don’t have that weight of commit. here’s the filed issue – not sure whether the subversion leads will agree.
the perforce people in their 1998 pdf “high-level best practices in software configuration management”, presented that “trunk” and “mainline” were the same thing. they did now know then that rational, around the same time, was going to forever cast mainline as something else. they also don’t have this pdf on their site any more, which is a pity. you can still find it in google, unless they go through a dmca takedown exercise :-(
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
RAML vs. OAS: Which Is the Best API Specification for Your Project?
Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices
How To Manage Vulnerabilities in Modern Cloud-Native Applications