TFS Basics–Branching Visualization

I've been talking to a lot of customers recently about Team Foundation Server (TFS) as a source code control management (SCCM) tool. Some are coming from Visual SourceSafe while others are coming from other SCCM tools. Regardless of what SCCM tool they're coming from, the subject of branching always comes up, and the question of “how can determine if a change in one branch has made it into another branch?”

One of the coolest features we introduced in the TFS 2010 is the Branching Visualization feature. This feature allows you to see if a changeset in one branch has been added another branch or not. This is done by viewing the changeset history you’re looking at and selecting Track Changeset either from the context menu or from the toolbar.


You’ll be promoted by a dialog box to select which branches you want track the changeset through. In this example, we’ve made changes in the Dev branch and we’re going to check to see if it’s been promoted to the Main and Release branch.


Once you press the Visualize button, you will see if changeset has been promoted (or demoted) to the branch you’re looking for. The default view is hierarchy (Screenshot below on the left). This is a good way of viewing the branches it provides you with a glimpse of your branching strategy as well. In this example, the “Main” branch is where we started the project and we created two branches from it: Dev and Release1. All development is going to be put in the Dev branch, promoted to Main and then promoted to a release, in this case, Release1. An alternative way of viewing the branches is by viewing them by timeline (Screenshot below on the right).


Regardless of the view, in the screenshots, you can see that we haven’t promoted Changeset 26 to Main or Release1. To find out more about Changeset 26, double click on the changeset and you’ll see the changeset details in the Team Explorer Window. In this example, we have two Work Items associated with the changeset. One is a task and other is a code review. If you’re the person responsible to promote code from one branch to another, you might want to recommend taking advantage the Code Review feature we introduced in TFS 2012.You can then have an SOP (standard operating procedure) that only changesets with code reviews performed on them can be promoted.


To promote Changeset 26 to the Main branch, you simply click and drag the changeset from the source branch to the target branch. This will trigger the merge process against the new branch.

So what happens to the changeset you just merged? The merge will be added to the branch’s project on your local workspace. From there, you should follow your standard quality gates for ensuring that the code works in the branch, check it into TFS, and proceed with the next changeset to promote.

To learn more about branching and merging strategies, you should take a look at the Branching and Merging Guidance document our ALM Ranger Team put together.