Branching and Merging

Branching and merging refer to two different but related processes for managing the source code tree within the Team Foundation Server repository. These operations are often performed by development teams that need to execute on different versions of the code in parallel and then, at some point, bring those changes back together for a release path through the source tree.

Owing to both the nature of iterative development and the circumstances of the modern software market, development teams often have complex needs in terms of maintaining their source code tree. The source code tree is essentially a hierarchical look at the various code files that constitute a solution by version. To solidify the idea behind branching, let's discuss the problem space in the context of a work scenario.

Assume that a development team is hard at work on a market-revolutionizing piece of software. Part of the team's product plan involves a rapid version 1.0 release to really nail the fundamentals, with a very quick follow-up that contemplates some of the more difficult design problems. The product management team decides to tackle this effort with two different development teams. One will start the initial architecture and development work for version 1.0. When enough architecture, design, and code base exists, the second team will start working on version 2.0. Because their development phases overlap, in a sense, their source code will as well.

Consider the diagram in Figure 19.28; it depicts a versioned view of the source tree and highlights the need for the version 2.0 efforts to work from, or branch from, the initial 1.0 efforts. Then, at some point in time, the fully complete 1.0 bits will be merged into the 2.0 tree. Notice as well that the product team anticipates a patch release to address the inevitable issues in the 2.0 code base. These changes will also need to branch and merge in the source tree.

Figure 19.28. Branching and merging a source tree.


Branching, just as it sounds, is the act of copying code from the current source tree and putting that code into a new branch of the tree. An easy way to understand this concept is to think of this space in terms of folders: To branch is to take a current folder of code (called the source) and create a new folder with a copy of the source's code (called the target). In other words, you can think of branching as a file system copy operation: You take the files in one location and make a copy of them in another location. Development is then free to continue within both folders in a parallel fashion.

Branching in Team Foundation is performed using the Source Control Explorer. You first need to navigate to the source folder on the server; then you right-click on the folder and select Branch. In the Branch dialog box (see Figure 19.29), you provide a name for the new branch (or target folder) and select a version of code from the source folder. If you select the Lock New Branch option, this will prevent anyone else on the team from creating a branch with the same name. Click OK to create the branch; it will be immediately visible in the Source Control Explorer.

Figure 19.29. Branching source using the Source Control Explorer.


Merging is the opposite of branching: Instead of forking one element of the source tree, it combines two elements of the source tree into one.

As with branching, you kick off the process from the Source Control Explorer. Right-click one of the source folders that will participate in the merge and then select Merge.

The Source Control Merge Wizard (see Figure 19.30) will collect all the needed information about the merge operation. Specifically, you will be asked to provide

  • The source branch

  • The target branch

  • The changes you want to merge (all within the source branch or only specific changesets)

  • The source versions that you want to merge

Figure 19.30. Using the Source Control Merge Wizard.

Clicking Finish at the end of the wizard will complete the merge.

Microsoft Visual Studio 2005 Unleashed
Microsoft Visual Studio 2005 Unleashed
ISBN: 0672328194
EAN: 2147483647
Year: 2006
Pages: 195

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: