Κοινή χρήση μέσω


View command (Team Foundation Version Control)

TFS 2017 | TFS 2015 | TFS 2013

Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 | Visual Studio 2013

The view command retrieves a specific version of a file to a temporary folder on your computer and displays it.

Prerequisites

To use the view command, you must have the Read permission set to Allow. For more information, see Default TFVC permissions.

Syntax

tf view [/collection:TeamProjectCollectionUrl] [/console] [/recursive] [/output:localfile]
[/shelveset:shelvesetname[;owner]] [/noprompt] itemspec 
[/version:versionspec] [/login:username,[password]]

Parameters

Argument

Argument

Description

TeamProjectCollectionUrl

The URL of the project collection that contains a specific version of a file about which you want to retrieve information (for example, http://myserver:8080/tfs/DefaultCollection).

shelvesetname [:owner]

Identifies the shelveset. The optional owner argument is used to specify a shelveset that is not owned by the current user.

Itemspec

Identifies the file or folder to retrieve. For more information about how Team Foundation parses itemspecs to determine which items are within scope, see Use Team Foundation version control commands, Use options to modify how a command functions.

Note

You can specify more than one Itemspec argument.

Versionspec

Provides a value such as C3 for the /version option. For more information about how Team Foundation parses a version specification to determine which items are within its scope, see Use Team Foundation version control commands.

username

Provides a value to the /login option. You can specify a username value as either DOMAIN<em>UserName or UserName.

localfile

Provides the path of the folder to which you want to output the file.

Option

Option

Description

/console

Specifies that the file output should be directed to the console. This is useful if you want to write the file out to disk using console redirection (with a different name or location than the versioned item).

/recursive

Views all items in the specified directory and any subdirectories.

/shelveset

Specifies the shelveset by name.

/noprompt

Specifies that Team Foundation should not prompt you before displaying each file when you include a wildcard in an itemspec that matches more than one file.

/version

Specifies the version of the file to open for viewing. If you omit this option, view retrieves the latest Team Foundation version control server version.

/collection

Specifies the project collection.

/login

Specifies the user name and password to authenticate the user with Azure DevOps.

/output

Outputs the file to a local folder instead of invoking a Windows shell to open the file.

Remarks

The >view command of the tf command-line utility retrieves a read-only copy of a file from the Team Foundation version control server to a temporary folder on your computer and displays its contents. Unless you specify a particular version, Team Foundation retrieves the latest version of the file from the Team Foundation version control server.

The view command does not retrieve files into your workspace or check them out. See Get Command and Checkout and Edit Commands for more information about how to get the Team Foundation version control server version of and check out files.

You can use the Difference Command to view the differences between two versions of a file.

For more information on how to find the tf command-line utility, see Use Team Foundation version control commands.

Output Options

By default, Team Foundation displays the contents of the file in the viewer associated with its file type.

If you include the /console option, Team Foundation prints the contents of the file to the command console. Likewise, if Team Foundation cannot locate a viewer for the type of file you have specified, it prints the contents of the file to the command console.

Finally, you can redirect the contents of a file to standard out using | or > in order to save it in another file or pass it to another program for post-processing.

Examples

The following example displays the latest version of the file 314.cs.

c:\projects>tf view 314.cs

The following example displays the version of 314.cs that was checked in with changeset 1999.

c:\projects>tf view /version:C1999 314.cs

The following example retrieves version 5 of 314.cs and writes it to the file 314.old.

c:\projects>tf view /version:5 314.cs > 314.old

The following example displays the latest version of each file that matches the wildcard "*.cs".

c:\projects>tf view *.cs