Wednesday, March 24, 2010

Branching in Subversion

Subversion has a very powerful branching and merging facility with recursive merges, feature branches, and tree merges. But before starting with the actual branching & merging, you need to fix on the branching & merging strategy.

Branching
A branching strategy should first focus on deciding what a branch represents. Common approaches to branching are:

Release based - every release is a new branch.






Branching by Project Phase - Development/ Test/ Production


Branching by Variant - Some products are built for various technology platforms. The branching strategy could hence depend on the architecture of the product.


The above mentioned strategies can be used in a combination, based on the project requirement. For example, a complex product built for Windows and Linux platforms could have a branching strategy as shown below.


Using Tortoise SVN for Branching
Tortoise SVN has an excellent help document on the branching and merging. You can also refer the SVN book for the same. While branching, you simply have to right click on the root folder from where you want to create branch and provide the branch path and name.


Best Practices:

  • Baseline code should be in "trunk" folder
  • All Branches should be created in a "Branch" folder
  • Branching and merging strategy should be decided before hand to avoid chaos later.
References: