Udostępnij za pośrednictwem


Branch Command

The branch command copies an item or set of items that includes metadata and version control history, from one location to another in the Team Foundation version control server and in the local workspace.

Note

The results of this command are not reflected in the Team Foundation version control server until you perform a check-in operation. For more information, see How to: Check In Pending Changes.

Required Permissions

To use the branch command, you must have the Read permission for the source item and the Check out permission for the target folder set to Allow. For more information, see Team Foundation Server Permissions.

tf branch olditem newitem [/version:versionspec] [/noget] [/lock:none|checkin|checkout] [/checkin] [/noprompt]

Parameters

Argument

Description

olditem

Specifies the name of the source file or folder being branched. The olditem may also contain version information in the format item;version.

Newitem

Specifies the name of the destination file or folder or the parent folder for the destination. If newitem already exists and is a Team Foundation version control server folder, Team Foundation creates the branched items in it. Otherwise, newitem specifies the name of the destination file or folder. Conflicts can occur during check-in if the destination already exists.

Versionspec

Provides a value for the /version option. For more information about how Team Foundation parses a version specification to determine which items are within its scope, see Command-Line Syntax (Team System).

Option

Description

/version

The version of the item at which you want to create the branch. You can specify a version by:

  • Date/time (D10/20/2005)

  • Changeset number (C1256)

  • Label (Lmylabel)

  • Latest version (T)

  • Workspace (Wworkspacename)

If no version is provided, Team Foundation uses the following logic to decide which version of the item to copy to the new branch:

  • If a Team Foundation version control server path is specified, Team Foundation branches the item at the latest Team Foundation version control server version. For example, tf branch $/projects/help.cs uses the server version.

  • If a local path is specified for the source, Team Foundation uses the local, workspace version to create the new branch. For example, tf branch C:\314.cs uses the local workspace version.

If you branch a file whose workspace version is older than the latest version in the Team Foundation version control server, the file is branched at the older version.

/lock

Prevents other users from checking in or checking out items until you check in your pending branch and associated changes. For more information, see Understanding Lock Types.

Lock Options:

  • None

    Default. No lock is applied. If a lock exists on the file that you are creating a branch for, this option removes it.

  • Checkin

    Other users can check out the specified items but they cannot check in revisions to locked files until you release the lock by performing a check-in. If any other users have locked any one of the specified items, the lock operation fails.

  • Checkout

    Prevents other users from checking in or checking out any one of the specified items until you release the lock by performing a check-in. If any other users have locked any one of the specified items, the lock operation fails.

/noget

If this option is specified, local copies of the files and folders in the new branch are not created in the local workspace. However, local copies will be retrieved into the workspace the next time that you perform a recursive Get operation.

Note

You can prevent items, such as the contents of an /images folder, from being retrieved to your workspace during recursive Get and Get Latest operations by cloaking a workspace folder. For more information, see Workfold Command.

/checkin

For use only with the Service Pack 1 version of Microsoft Visual Studio Team System 2008 Team Foundation Server.

Checks in the branch action at the same time the branch is created.

/noprompt

Suppresses any prompts for input from you.

Remarks

If you specify a local path such as c:\00101 but do not specify a versionspec, Team Foundation uses the local workspace version as the basis for creating the new branch.

However, if you specify a server path such as $/00101/*.cs and do not specify a versionspec, Team Foundation uses the latest Team Foundation version control server version as the basis for creating the new branch instead.

For more information about how to find the tf command-line utility, see Tf Command-Line Utility Commands.

Examples

The following example creates a branch file that contains the latest workspace version of 314.cs, names it "314_branch", and then saves it to the current directory on disk and also to the Team Foundation version control server folder to which it maps.

c:\projects>tf branch 314.cs 314_branch

The following example copies all the files without pending edits in the workspace version of 314.cs from its current Team Foundation version control server folder into the testdata Team Foundation version control server folder and from the current directory on disk to the working folder that maps to the testdata Team Foundation version control server folder.

c:\projects>tf branch C:\314.cs $/testdata

The following example copies all the files without pending edits in the current workspace version of the testfiles folder and the files it contains for all items from its current Team Foundation version control server folder into the testfiles_branch Team Foundation version control server folder and from c:\testfiles into the local folder that maps to the testfiles_branch Team Foundation version control server folder.

c:\projects>tf branch C:\testfiles $/testfiles_branch

The following example creates a branch of 314.cs as it existed in changeset #4 for the file. In the working folder on disk, as in the Team Foundation version control server, a branch file titled csharp_branch is created.

c:\projects>tf branch C:\314.cs;C4 csharp_branch

The following example creates a new branch of 314.cs as it was on 12/12/03. In the working folder on disk as in the Team Foundation version control server, a branch file titled 314_branch is created.

c:\projects>tf branch 314.cs;D12/12/03 314_branch

The following example branches the version of 314.cs to which the "Beta1" label was applied, names it "Beta1branch," and saves it to the current directory on disk in addition to the Team Foundation version control server folder to which the current directory maps.

c:\projects>tf branch 314.cs;LBeta1 314_Beta1branch

See Also

Tasks

Walkthrough: Advanced Functionality of Version Control

Walkthrough: Working with Team Foundation Version Control from the Command Line

How to: Branch Files and Folders

Concepts

Understanding Branching

Working with Version Control Changesets

Reference

Branches Command

Merge Command

Other Resources

Tf Command-Line Utility Commands