Muokkaa

Jaa


View command (Team Foundation Version Control)

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Visual Studio 2019 | Visual Studio 2022

The Team Foundation Version Control (TFVC) view command retrieves a specific version of a file, stores it in 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:<team-project-collection-url>] [/console] [/recursive] [/output:<local-file>]
[/shelveset:<shelveset-name>[;<owner>]] [/noprompt] <item-spec> 
[/version:<version-spec>] [/login:<username>,[<password>]]

Parameters

The following sections describe arguments and options of the view command.

Arguments

Argument

Description

<team-project-collection-url>

Provides the URL of the project collection that contains a specific version of a file that you want to retrieve information about, for example, https://myserver:8080/tfs/DefaultCollection.

<shelveset-name> [:<owner>]

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

<item-spec>

Identifies the file or folder to retrieve. For more information about how TFVC parses the <item-spec> argument 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 <item-spec> argument.

<version-spec>

Provides a value such as C3 for the /version option. For more information about how TFVC 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 this value as either DOMAIN\<username> or <username>.

<password>

Provides a value to the /login option.

<local-file>

Provides the path to the output file folder.

Options

Option

Description

/console

Specifies that the file output should be directed to the console. This option is useful if you want to write the file to disk by using console redirection but use 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 TFVC shouldn't prompt you before displaying each file when you include a wildcard expression in an <item-spec> argument 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 Azure DevOps server version.

/collection

Specifies the project collection.

/login

Specifies the username 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 Azure DevOps server, stores the file in a temporary folder on your computer, and displays the file contents. Unless you specify a particular version, TFVC retrieves the latest version of the file from the Azure DevOps server.

The view command doesn't add files to your workspace or check them out. For more information about how to get the Azure DevOps server version of a file and check it out, see Get command and Checkout and Edit commands.

You can use the difference command to view the differences between two versions of a file. For more information, see Difference command.

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

Output options

  • By default, TFVC displays the contents of the file in the viewer that's associated with its file type.

  • If you include the /console option, TFVC prints the contents of the file to the command console. Likewise, if TFVC can't locate a viewer for the type of file that you specified, it prints the file contents to the command console.

  • You can redirect the contents of a file to standard output by using | or \>. This option provides a way to save the file to 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 expression *.cs:

c:\projects>tf view *.cs