This project has moved. For the latest updates, please go here.

Beginners Question - Basic Branch Plan

May 12, 2011 at 10:31 AM

Hi, I am completely new to branching and am trying to figure out how to apply the basic branch plan to an existing solution.  We have one solution file containing 11 projects, a mixture of web application, shared class libraries, web services, database projects etc...

The structure is as follows:

>Solution
 -ClassLibrary1
 -WebProject
 -WebService1
 -ClassLibrary2
 -DatabaseProject1
 -DatabaseProject2
 -WebService2

The main project I would like to add branching to (at least to start with) is the web project and i want to know exactly how to structure things, and where to create the branch.

Should I branch at the WebProject folder level, which also contains the project file? Do I then need to add this new branch to the solution? Wouldn't this give a naming conflict?

Should I create a sub-folder for 'Main' and move all of my existing code in to this and then branch from there in to other sub folders?  How would this affect my folder structure when I deploy the web project (I don't want a 'Main'/'Release' folder created when I deploy to my production web server.

Sorry if this is really basic, but it hasn't quite 'clicked' with me how I should get this started.

Thanks in advance,

Ian

Developer
May 13, 2011 at 8:45 PM

Since I don't know how much you already understand about TFS / Team Projects / Branching, etc. Let me start with some basics.

  • Start by creating a Team Project to contain all of the eleven (11) projects in your solution. For discussion purposes, I will call this TeamProject1 ($/TeamProject1).
  • Create a workspace mapping for this Team Project. (Map $/TeamProject1 to a local folder on your workstation (for example c:/ws/TeamProject1)
  • Next, create a folder called Main in the Team Project. ($TeamProject1/Main) - this will be the folder that contains your MAIN branch.
  • Next create a folder called Development (at the same level as Main) ($TeamProject1/Development)) - this will be the folder that contains your Development branch(es)
  • Next create a folder called Release (at the same level as Main and Development) ($TeamProject1/Release)  - this will be the folder that contains your Release branch(es)
  • Check-in all pending changes
  • Next, inside the folder Main, create another folder, Main ($/TeamProject1/Main/Main). 
  • Check-in all pending changes
  • Convert this (second Main) folder to a first-class branch (MAIN)
  • Under the MAIN branch create a folder to hold your source code ($/TeamProject1/Main/MAIN/Src)
  • Create a folder for you solution, for discussion purposes, I will call this Solution1 ($/TeamProject1/Main/MAIN/Src/Solution1)
  • Put your solution file (Solution1.sln) under this folder
  • Each of your projects will be in folders under the Solution1 folder (for example $/TeamProject1/Main/MAIN/Src/Solution1/ClassLibrary1 will contain ClassLibrary1.csproj and $/TeamProject1/Main/MAIN/Src/Solution1/ClassLibrary2 will contain ClassLibrary2.csproj)
  • When you branch (for example to create a development branch) you would branch $/TeamProject1/Main/MAIN -> $/TeamProject1/Development/DEV1).
  • After branching you will see all of the folders and source code files under the MAIN branch are now also under the DEV1 branch (for example, you will now see $/TeamProject1/Development/DEV1/Src/Solution1/WebProject, etc)

Since your solution is contained in a folder under the branch (MAIN or DEV1), you could build and deploy your solution and it would not deploy its containing folders/branches)

I hope this helps,

Regards,
Bill Heys
VS ALM Ranger

May 16, 2011 at 1:16 PM

Hi Bill, thanks for the comprehensive reply.  I have not tried this but I think I understand what you are suggesting - we'll soon see :-)

In the layout you are suggesting above, when I create a branch, i.e. to create a development branch, I would be branching the entire solution, is that correct?  In our setup it is mainly the web project/class library that is getting worked on and the other projects are fairly stable, would creating a branch of the whole solution be overkill if I am, for example, only updating the web project?

Thanks again for your assistance.

Ian

Developer
May 16, 2011 at 2:07 PM

 

I would be inclined to branch all of the code for the solution, and not simply for individual projects. This will ensure that if you do need, at some point, to make changes to other parts of the solutions, it will stay in sync.

There is minimal overhead to branching – until such time as you make changes: http://blogs.msdn.com/b/billheys/archive/2011/05/05/how-tfs-stores-files-and-calculated-deltas-on-versioned-files.aspx

 Regards,
Bill Heys
VS ALM Ranger

May 16, 2011 at 4:15 PM

Thanks Bill,

I have given this a go and the structure has worked in such that my solution loads up under my dev branch, so I can now see how this goes in practice.

Thanks,

Ian

Oct 9, 2013 at 9:54 AM
Why do we need to have two Main folders? Can't we branch from the top level main folder? I'm referring to $/TeamProject1/Main/MAIN
Developer
Oct 9, 2013 at 12:33 PM
This is actually not two folders named "Main". Rather this a is true branch "MAIN" which has been created in a folder, "Main". There is a technical reason for doing this, rather than having the "MAIN" branch located directly under the Team Project. Primarily this had to do with relative project references.