Version Control Structure – Best Practice

Bottom line up front:  Create a ‘root’ branch directly under the source control branch associated with a new Team Project.

I see this all the time…  Someone creates a new source control branch in TFS and starts creating solutions underneath the default project branch.  In other words, they end up with this:

$/ProjectName
    /SolutionName1
        /ProjectName1
        /ProjectName2
    /SolutionName2
        /ProjectName3
        /ProjectName4

Now, the difficult comes when the shop needs to create a second version of the application.  Code branches directly under the root (i.e., $/ProjectName) can only be created when a new Team Project is created.  If, in the above example, SolutionName1 and SolutionName2 both belong to the current version of the application, then creating a new version of the application will require either the creation of a new team project (with a branch from the $/ProjectName), or a wildly unweildly structure where each solution is branched, resulting in something like:

$/ProjectName
    /SolutionName1
        /ProjectName1
        /ProjectName2
    /SolutionName2
        /ProjectName3
        /ProjectName4
    /SolutionName1_v2
        /ProjectName1
        /ProjectName2
    /SolutionName2_v2
        /ProjectName3
        /ProjectName4

A MUCH cleaner approach is so simple, yet requires a bit of forethought.  Immediately after creating the Team Project, simply go in an create a new directory called ‘root’ (or ‘edge’ or whatever you’2013-08-28 13:42:11’d like).  You can then create a full branch of the V1 off the application by simply branching ‘root’.  This allows This resulting in the following structure, even after creating a v2 of the project.

$/ProjectName
    /root                           <– Create this branch!
        /SolutionName1
            /ProjectName1
            /ProjectName2
        /SolutionName2
            /ProjectName3
            /ProjectName4
    /ProjectName_v2      <– This is the branch of ‘root’
        /SolutionName1
            /ProjectName1
            /ProjectName2
        /SolutionName2
            /ProjectName3
            /ProjectName4

Now, whether you should have your projects under your solution directories…  that’s for another post…