<p>The company I work for is starting to have issues with their current branching model and I was wondering what different kinds of branching strategies the community has been exposed to?</p>

<p>Are there any good ones for different situations?  What does your company use?  What are the advantages and disadvantages of them??</p>

[{'answer_id': 34991, 'author': 'Corey McKinnon', 'author_id': 633, 'author_profile': 'https://Stackoverflow.com/users/633', 'pm_score': 2, 'selected': False, 'text': '<p>We currently have one branch for ongoing maintenance, one branch for "new initiatives" which just means "stuff that will come out sometime in the future; we\'re not sure when." We have also occasionally had two maintenance branches going on: one to provide fixes for what is currently in production and one that is still in QA.</p>\n\n<p>The main advantage we\'ve seen is the ability to react to user requests and emergencies more rapidly.  We can do the fix on the branch that is in production and release it without releasing anything extra that may have already been checked in.</p>\n\n<p>The main disadvantage is that we end up doing a lot of merging between branches, which increases the chance that something will get missed or merged incorrectly. So far, that hasn\'t been a problem, but it is definitely something to keep in mind.</p>\n\n<p>Before we instituted this policy, we generally did all development in the trunk and only branched when we released code. We then did fixes against that branch as needed. It was simpler, but not as flexible.</p>\n'}, {'answer_id': 35015, 'author': 'mk.', 'author_id': 1797, 'author_profile': 'https://Stackoverflow.com/users/1797', 'pm_score': 1, 'selected': False, 'text': '<p>The philosophy that we follow at work is to keep the trunk in a state where you can push at any time without drastic harm to the site. This is not to say that the trunk will always be in a perfect state. There will of course be bugs in it. But the point is to never, ever leave it broken drastically.</p>\n\n<p>If you have a feature to add, branch. A design change, branch. There have been so many times where I thought, "oh I can just do this in the trunk it isn\'t going to take that long", and then 5 hours later when I can\'t figure out the bug that is breaking things I really wished that I had branched.</p>\n\n<p>When you keep the trunk clean you allow the opportunity to quickly apply and push out bug fixes. You don\'t have to worry about the broken code you have that you conveniently branched off.  </p>\n'}, {'answer_id': 35016, 'author': 'Misha M', 'author_id': 3467, 'author_profile': 'https://Stackoverflow.com/users/3467', 'pm_score': 0, 'selected': False, 'text': '<p>For Subversion, I agree with Ryan Duffield\'s comment.  The chapter he refers to provides a good analyses on which system to use.</p>\n\n<p>The reason I asked is that Perforce provides a completely different way to create branches from SVN or CVS.  Plus, there are all the DVCSs that give it\'s own philosophy on branching.  Your branching strategy would be dictated by which tool(s) you\'re using.</p>\n\n<p>FYI, <a href="http://www.orcaware.com/svn/wiki/Svnmerge.py" rel="nofollow noreferrer">Svnmerge.py</a> is a tool to assist with merging branches in SVN.  It works very well as long as you use it frequently ( every 10-30 ) commits, otherwise the tool can get confused.</p>\n'}, {'answer_id': 35044, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>We branch when a release is ready for final QA.  If any issues are discovered during the QA process, the bugs are fixed in the branch, validated and then merged to the trunk.  Once the branch passes QA we tag it as a release.  Any hotfixes for that release are also done to the branch, validated, merged to the trunk and then tagged as a separate release.</p>\n\n<p>The folder structure would look like this (1 QA line, 2 hotfix releases, and the trunk):</p>\n\n<blockquote>\n  <p>/branches</p>\n  \n  <blockquote>\n    <p>/REL-1.0</p>\n  </blockquote>\n  \n  <p>/tags</p>\n  \n  <blockquote>\n    <p>/REL-1.0</p>\n    \n    <p>/REL-1.0.1</p>\n    \n    <p>/REL-1.0.2</p>\n  </blockquote>\n  \n  <p>/trunk</p>\n</blockquote>\n'}, {'answer_id': 35083, 'author': 'jcoby', 'author_id': 2884, 'author_profile': 'https://Stackoverflow.com/users/2884', 'pm_score': 6, 'selected': False, 'text': "<p>Here is the method I've used in the past with good success:</p>\n\n<p>/trunk - bleeding edge.  Next major release of the code.  May or may not work at any given time.</p>\n\n<p>/branches/1.0, 1.1, etc.  Stable maintenance branches of the code.  Used to fix bugs, stabilize new releases.  If a maintenance branch, it should compile (if applicable) and be ready for QA/shipping at any given time.  If a stabilization branch, it should compile and be feature complete.  No new features should be added, no refactoring, and no code cleanups.  You can add a pre- prefix to indicate stabilization branches vs maintenance branches.</p>\n\n<p>/branches/cool_feature.  Used for highly experimental or destructive work that may or may not make it into trunk (or a maintenance branch).  No guarantees about code compiling, working, or otherwise behaving sanely.  Should last the minimum time as possible before merging into the mainline branch.</p>\n\n<p>/tags/1.0.1, 1.0.2, 1.1.3a, etc.  Used for tagging a packaged &amp; shipped release.  Never EVER changes.  Make as many tags as you want, but they're immutable.</p>\n"}, {'answer_id': 35095, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 2, 'selected': False, 'text': '<p>We use the wild, wild, west style of git-branches.  We have some branches that have well-known names defined by convention, but in our case, tags are actually more important for us to meet our corporate process policy requirements.</p>\n\n<p>I saw below that you use Subversion, so I\'m thinking you probably should check out the section on branching in the <a href="http://svnbook.red-bean.com/" rel="nofollow noreferrer">Subversion Book</a>.  Specifically, look at the "repository layout" section in <a href="http://svnbook.red-bean.com/nightly/en/svn.branchmerge.maint.html" rel="nofollow noreferrer">Branch Maintenance</a> and <a href="http://svnbook.red-bean.com/nightly/en/svn.branchmerge.commonpatterns.html" rel="nofollow noreferrer">Common Branch Patterns</a>.</p>\n'}, {'answer_id': 59510, 'author': 'Andrew Burns', 'author_id': 3683, 'author_profile': 'https://Stackoverflow.com/users/3683', 'pm_score': 3, 'selected': False, 'text': '<p>Our repository looks like:</p>\n\n<pre><code>/trunk\n/branches\n/sandbox\n/vendor\n/ccnet\n</code></pre>\n\n<p><strong>/trunk</strong> is your standard, bleeding edge development.  We use CI so this must always build and pass tests.</p>\n\n<p><strong>/branches</strong>  this is where we put \'sanctioned\' large changes, ie something we KNOW will make it into trunk but may need some work and would break CI.  Also where we work on maintenance releases, which have their own CI projects.</p>\n\n<p><strong>/sandbox</strong>  each developer has their own sandbox, plus a shared sandbox.  This is for things like "Lets add a LINQ provider to our product" type of tasks that you do when you are not doing your real work.  It may eventually go into trunk, it may not, but it is there and under version control.  No CI here.</p>\n\n<p><strong>/vendor</strong>  standard vendor branch for projects where we compile but it is not code that we maintain.</p>\n\n<p><strong>/ccnet</strong>  this is our CI tags, only the CI server can write in here.  Hindsight would have told us to rename this to something more generic such as CI, BUILDS, etc.</p>\n'}, {'answer_id': 64996, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>The alternative I\'m not seeing here is a "Branch on Change" philosophy.</p>\n\n<p>Instead of having your trunk the "Wild West", what if the trunk is the "Current Release"?  This works well when there is only one version of the application released at a time - such as a web site.  When a new feature or bug fix is necessary a branch is made to hold that change.  Often this allows the fixes to be migrated to release individually and prevents your cowboy coders from accidentally adding a feature to release that you didn\'t intend. (Often it\'s a backdoor - "Just for development/testing")</p>\n\n<p>The pointers from Ben Collins are quite useful in determining what style would work well for your situation.</p>\n'}, {'answer_id': 795566, 'author': 'pablo', 'author_id': 72456, 'author_profile': 'https://Stackoverflow.com/users/72456', 'pm_score': 3, 'selected': False, 'text': '<ol>\n<li>One branch for the active development (/main or master, depending on the jargon)</li>\n<li>One branch for each maintenance release -> it will receive only really small fixes, while all major development goes to /main</li>\n<li>One branch for each new task: create a new branch to work on every new entry on your Bugzilla/Jira/Rally. Commit often, self document the change using inch pebble checkins, and merge it back to its "parent" branch only when it\'s finished and well tested.</li>\n</ol>\n\n<p>Take a look at this <a href="http://codicesoftware.blogspot.com/2010/03/branching-strategies.html" rel="noreferrer">http://codicesoftware.blogspot.com/2010/03/branching-strategies.html</a> for a better explanation</p>\n'}, {'answer_id': 2461043, 'author': 'bo bo', 'author_id': 67706, 'author_profile': 'https://Stackoverflow.com/users/67706', 'pm_score': 0, 'selected': False, 'text': '<p>No matter which branching pattern chosen, you should try to keep your branches in a binary tree form like this:</p>\n\n<pre><code>   trunk - tags\n     |\n    next\n   /  \\  \\\nbugfix  f1  f2\n        /   \\  \\          \n       f11    f21 f22\n</code></pre>\n\n<ul>\n<li>Child nodes should only merge with the direct parent.</li>\n<li>Try ur best to merge only the whole branch with the parent branch. never merge subfolders within a branch.</li>\n<li>You may cherry pick commits when needed as long as you only merge and pick from whole branch.</li>\n<li>The next branch in the above figure is only for illustration, you may not need it.</li>\n</ul>\n'}, {'answer_id': 4605364, 'author': 'hfrmobile', 'author_id': 254829, 'author_profile': 'https://Stackoverflow.com/users/254829', 'pm_score': 3, 'selected': False, 'text': "<p>The first thing: <strong>KISS</strong> (Keep it simple stupid!)</p>\n\n<pre>\n/branches\n  /RB-1.0 (*1)\n  /RB-1.1 (*1)\n  /RB-2.0 (*1)\n/tags\n  /REL-1.0 (or whatever your version look like e.g. 1.0.0.123 *2)\n  /REL-1.1\n  /REL-2.0\n/trunk\n  current development with cool new features ;-)\n</pre>\n\n<p>*1) Keep version maintainable - e.g. Service Packs, Hotfixes, Bugfixes which may be merged to trunk if necessary and/or needed)\n*2) major.minor.build.revision</p>\n\n<p><strong>Rules of the thumb:</strong></p>\n\n<ol>\n<li>The Tags folder need not to be checked out</li>\n<li>Only few coding in release branches (makes merging simpler) - no code cleanup etc.</li>\n<li>Never to coding in tags folder</li>\n<li>Never put concrete version information into source files. Use Place-holders or 0.0.0.0 which the build mechanism will replace by the version number you're building</li>\n<li>Never put third party libraries into your source control (also no one will add STL, MFC etc. libraries to SVN ;-))</li>\n<li>Only commit code that compiles</li>\n<li>Prefer using environment variables instead of hard-coded paths (absolute and relative paths)</li>\n</ol>\n\n<p>--hfrmobile</p>\n"}, {'answer_id': 7820398, 'author': 'Chris S', 'author_id': 21574, 'author_profile': 'https://Stackoverflow.com/users/21574', 'pm_score': 2, 'selected': False, 'text': '<p>Gnat has written <a href="https://softwareengineering.stackexchange.com/questions/107884/to-branch-or-not-to-branch/108298#108298">this excellent break down</a> on the various bits of advice your can find on branching strategies.</p>\n\n<p>There\'s not one branching strategy, it\'s what works for:</p>\n\n<ul>\n<li>Your team size</li>\n<li>Your product and the lifecycle periods</li>\n<li>The technology you\'re using (web, embedded, windows apps)</li>\n<li>Your source control, e.g. Git, TFS, Hg</li>\n</ul>\n\n<p>Jeff Atwood\'s <a href="http://www.codinghorror.com/blog/2007/10/software-branching-and-parallel-universes.html" rel="nofollow noreferrer">post</a> breaks down a lot of possibilities. Another to add is the concept of promotion (from Ryan Duffield\'s link). In this setup you have a dev branch, test bracnh and release branch. You promote your code up until it reaches the release branch and is deployed.</p>\n'}]
['https://Stackoverflow.com/questions/34975', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2328/']