Branching Files and Folders (Team Explorer Everywhere)

You can use branches to accomplish the following tasks:

  • Manage concurrent work by multiple teams on the same code base.

  • Isolate risks that are introduced by different sets of changes to the code base.

  • Take snapshots and then support subsequent isolated changes (for example, to create a release or servicing branch).

For example, the following illustration shows how the fictional DinnerNow company developed a branch structure to meet its business needs:

VcViewHierarchyExample

Feature Team A and Feature Team B each does its work in separate branches. When the teams are ready to integrate their work, they merge their branches into the Dev branch. When the builds from the Dev branch are stable and ready to test, the teams merge the Dev branch into the Test branch.

As each version is released, the Main branch is branched into a new version branch, such as the Version1 branch and the Version2 branch. By following this strategy, the company can enhance or fix each past version of the product separately.

Note

Branching is an important and powerful technique that your team can use to create an alternate set of versions of your files. However, branches can add complexity and cost to your project. For example, you might have to resolve conflicts when you merge branches.

Before you create a branch, you should consider whether you can better meet your needs by applying a label. By applying a label, you can quickly and easily take a snapshot of the state of your files so that you can then later retrieve or build the files in that state. For more information, see Use Labels to Take a Snapshot of Your Files (Team Explorer Everywhere).

In this topic

  • Convert a Folder to a Branch

  • Branch a Branch

  • Branch a Folder or File

Convert a Folder to a Branch

The release of Visual Studio Team Foundation Server 2010 started a distinction between branches and folders. The following illustration shows the top level of the folder structure for DinnerNow:

DinnerNow folder structure in Source Control Explorer

vcExplorerFoldersAndBranchesCalloutsTEE

As the illustration shows, you can still use folders to organize branches in the hierarchy of the file system for a team project under version control. However, folders and branches have a different appearance and different capabilities. When you right-click a folder or branch and then click Properties, you display different information and different functionality.

When you perform branch operations, branches have important advantages over folders. Branches support version control features that provide extra visibility into your branch structure and into where your changesets have merged.

Important

In the Visual Studio client for Team Foundation Server 2010, you can display a visual representation of your branches. This branch visualization is not available in Team Explorer Everywhere 2010.

You cannot nest branches. Therefore, you cannot convert any folder to a branch if it either contains a branch or is contained by a branch. For example, the following illustration shows how neither the parent nor the child of the FeatureTeamA branch can be converted to a branch.

Nested branches are not allowed

You can still branch and merge among folders, but the best practice is to branch and merge only among branches. The following procedure explains how to convert a folder to a branch.

Required Permissions

To perform the following procedure, your Manage branch permission must be set to Allow. For more information, see the following page on the Microsoft website: Team Foundation Server Permissions.

Note

You cannot use the Cross-platform Command-Line Client for Team Foundation Server to convert a folder to a branch.

To convert a folder to a branch

  1. In Source Control Explorer, right-click the folder that you want to convert, and then click Convert to Branch.

    The Convert Folder to Branch dialog box appears.

    Important

    If you are converting a folder that you have already branched, select the Recursively perform this conversion for all branched child folders check box. This option also converts to branches all folders that were branched from this one folder.

  2. (Optional) In Owner, type the name of the user who owns this branch.

    Note

    The Owner field is for information only. No additional permissions are granted to the user who is named in the Owner field.

  3. (Optional) In Description, type information that you think might help other team members who must use this branch or understand its purpose.

  4. Click Convert.

Branch a Branch

After you have converted a folder to a branch, you can then create other branches from that branch.

Required Permissions

To perform this procedure, your Manage branch permission must be set to Allow for the paths of the source and target branches. Your Merge permission for the path of the target branch must be set to Allow. For more information, see the following page on the Microsoft website: Team Foundation Server Permissions.

Important

You cannot use the Cross-platform Command-Line Client for Team Foundation Server to branch a branch.

To branch a branch

  1. In Source Control Explorer, right-click the branch that you want to branch, and then click Branch.

    The Branch from dialog box appears.

  2. In Target Branch Name, specify the path of the new branch.

  3. (Optional) In the By list, click one of the following options:

    • If you click Latest Version, the branch is created for the most recent version in version control.

    • If you click Changeset, you can specify the number of the changeset in the Changeset box. As an alternative, click the ellipses (...) to open the Find Changesets dialog box.

      For more information, see Search for a Changeset.

    • If you click Label, you can type the label name in the Label box. As an alternative, you can also click the ellipses (...) to open the Find Label dialog box.

      For more information, see List, Find, View, Edit, and Remove Labels.

    • If you click Date, you can specify a date in the Date box.

    • If you click Workspace Version, you can specify a computer and a Team Foundation Server workspace in the Workspace box.

  4. Click Branch.

Branch a Folder or File

Important

In most cases, this procedure is not a best practice. However, in Visual Studio Team System 2008 Team Foundation Server and Visual Studio 2005 Team Foundation Server, you can use only this kind of branching. You cannot convert folders to branches or branch a branch.

You can still branch a folder or file directly, but this kind of operation is typically not the best approach for most purposes. The best practice is to branch and merge only among branches, as described earlier in this topic.

Required Permissions

To perform this procedure, your Check out permission and your Merge permission for the target path must be set to Allow. For more information, see the following page on the Microsoft website: Team Foundation Server Permissions.

To branch a folder or file

  1. In Source Control Explorer, right-click the folder or file that you want to branch, and then click Branch.

    The Branch dialog box appears.

  2. In Target, modify the location and the name of the new branch.

    You can also click Browse to specify a target.

  3. In the By list, click one of the following options:

    • If you click Latest Version, the branch is created for the most recent version in version control.

    • If you click Changeset, you can specify the number of the changeset in the Changeset box. As an alternative, click the ellipses (...) to open the Find Changesets dialog box.

      For more information, see Search for a Changeset.

    • If you click Label, you can type the label name in the Label box. As an alternative, you can also click the ellipses (...) to open the Find Label dialog box.

      For more information, see List, Find, View, Edit, and Remove Labels.

    • If you click Date, you can specify a date in the Date box.

    • If you click Workspace Version, you can specify a computer and a Team Foundation Server workspace in the Workspace box.

  4. (Optional) Select the Create local working copies for the new branch check box to create a copy of the version-controlled item on the local workspace. Clear the check box if you do not need a local copy and you want to improve performance by not downloading many items to your computer.

  5. (Optional) Select the Convert source and target folders to branches check box to convert both the source and the target folders to branches. Clear the check box if you want to convert only the target folder to a branch.

  6. Click OK.

    The branch is created and appears in Source Control Explorer.

    A Browse for Folder window appears if you selected the Create local working copies for the new branch check box and if the local folder that you specified is not mapped in the current workspace.

  7. (Optional) Browse for a folder or click Make New Folder, specify a folder to synchronize to the version-controlled items, and then click OK.

To branch a folder or file at a command prompt

  • At a command prompt, type tf branch ItemSpec BranchName, and then press ENTER.

    Replace ItemSpec with the name of the file or folder that you want to branch. Replace BranchName with the name of the branch that you want to create.

    For more information, see the following page on the Microsoft website: Branch Command (Team Foundation Version Control).

See Also

Other Resources

Branching and Merging (Team Explorer Everywhere)

Use Labels to Take a Snapshot of Your Files (Team Explorer Everywhere)

Merging Files and Folders (Team Explorer Everywhere)