Branch Command
The branch command copies an item or set of items, including metadata and source control history, from one location to another in the Team Foundation source control server and in the local workspace.
Note
The results of this command are not reflected in the Team Foundation source control server until you perform a check-in operation. For more information, see How to: Check In Pending Changes.
tf branch olditem newitem [/version:versionspec] [/noget]
[/lock] [/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 source control server folder, Team Foundation creates the branched items within 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. |
Option | Description |
---|---|
/version |
The version of the item at which you want to create the branch. You can specify a version by:
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 you branch a file whose workspace version is older than the latest version in the Team Foundation source 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:
|
/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. |
/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 source control server version as the basis for creating the new branch instead.
Examples
The following example creates a branch file that contains the latest workspace version of 314.cs, names it "314_branch", and saves it to the current directory on disk and also to the Team Foundation source 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: a) from its current Team Foundation source control server folder into the testdata Team Foundation source control server folder and b) from the current directory on disk to the working folder that maps to the testdata Team Foundation source 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: a) from its current Team Foundation source control server folder into the testfiles_branch Team Foundation source control server folder and b) from c:\testfiles into the local folder that maps to the testfiles_branch Team Foundation source 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 source 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 source 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 source control server folder to which the current directory maps.
c:\projects>tf branch 314.cs;LBeta1 314_Beta1branch
Security
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.
See Also
Tasks
Walkthrough: Advanced Functionality of Source Control
Walkthrough: Working with Team Foundation Source Control from Command Line
How to: Branch Files and Folders
Reference
Branches Command
Merge Command
Concepts
Source Control Security Rights and Permissions
Understanding Branching
Working with Source Control Changesets