Get Command

Retrieves a read-only copy of a file from the Team Foundation Server to the workspace and creates folders on disk to contain it.

tf get itemspec [/version:versionspec] [/all] [/overwrite] [/force] 
[/preview] [/recursive] [/noprompt]

Parameters

Argument Description

Itemspec

File or folder to retrieve. If no itemspec is provided, Team Foundation Server performs a recursive get operation of the current workspace.

Versionspec

The user-provided value for the /version option. For more information about how Team Foundation Server parses a version specification to determine which items are within its scope, see Command-Line Syntax.

Option Description

/version

Optional version specification. The versionspec is the version of the item you want to retrieve. You can specify a version by:

  • Date/time (D10/20/2005)

  • Changeset version (C1256)

  • Label (Lmylabel)

  • Latest version (T)

  • Workspace version (Wworkspacename;owner)

  • If no version is provided, Team Foundation Server retrieves the latest server version of the specified itemspec into your workspace.

/all

Forces all files to be retrieved, not just those that are out-of-date.

/overwrite

Overwrites writable files that are not checked out.

/force

Implies /all and /overwrite.

/preview

Displays what would occur without actually performing the Get operation.

/recursive

Recursively retrieves all items that match your itemspec.

/noprompt

Suppresses any dialog boxes or error messages that would otherwise be displayed during this operation.

Remarks

The get command retrieves items from the server into a workspace. If no other version is provided, the latest server version is retrieved.

If you work in a team development environment, Get is the command you use most frequently because getting every file in the current project synchronizes with your team and makes sure that you have the very latest copy of shared work. The get command does not overwrite files that you have checked out in the local directory. The more frequently you perform the get command in a collaborative working environment, the more current the local files are with that of your team. That is because a get operation populates the local workspace with changes that have been checked into the server by your teammates. If you keep your workspace up-to-date by performing a Get Latest operation whenever you see a check-in notification, you can quickly resolve differences between your version of a project and the server version of the project. You can avoid making changes that might not be easy to reconcile with the server when you check in your pending changes.

During a get operation, if your workspace version is the same as the requested server version, Team Foundation Server does not replace the file on disk unless the /all option is specified. You can use the /overwrite option to forcibly overwrite the writable current workspace version with a specified server version in order to restore your workspace to a consistent state when it becomes unmanageable, such as sometimes occurs when you delete or accidentally overwrite multiple files on disk or when your computer is infected by a virus. When you pass the /force option, Team Foundation Server overwrites all items in the workspace with the latest server version unless you provide a specific version.

When you perform a get operation, Team Foundation Server deletes any checked-in files from the local workspace that have been deleted from the server after the last time that you synchronized your workspace to the server version. Files that have been renamed or moved on the server are relocated on disk to match the changes on the server.

You can use the /preview option to issue the get command without making updates to the local workspace in order to see what would occur if you were to perform an actual get operation.

Note

Be careful when retrieving single file revisions into a workspace, especially if its timestamp differs significantly from other related workspace items.

Workspaces that contain chronologically inconsistent file revisions can be more difficult to synchronize with the latest Team Foundation source control server version and when checked in, increase the chance that future check-ins can unintentionally introduce bugs into the build.

Checkout operation does not perform a get latest operation on files being checked out

When you perform a get operation to populate your workspace with a set of files, you are setting yourself up with a consistent snapshot from source control. Typically, the configuration of source on the system is a snapshot of files from the Team Foundation source control server that are known to work together, and can be built and tested.

As a developer working in a workspace, you are isolated from the changes that were made by other developers. You control when you accept changes from other developers by performing a get operation as appropriate. Ideally, you can update the complete configuration of source and not just one or two files because changes in one file typically depend on corresponding changes to other files. You must make sure that you have a consistent snapshot of the source that can be built and tested.

Therefore the check-out operation does not perform a get latest on the files checked out. Updating one file being checked out would violate the consistent snapshot and could give you a configuration of source that cannot be built or tested. Alternatively Team Foundation Server forces you to perform the get latest operation at some point before you check-in your changes so that when you try to check-in your changes, and you do not have the latest copy, you are prompted with the resolve conflicts dialog box.

The Get Process

When you perform a get operation, the version number of each item is recorded in the workspace definition and saved on the Team Foundation Server. This version of an item is referred to as the base workspace version.

When you issue a get command for an item from the server and that is already checked out in your workspace, you are prompted to resolve file conflicts between the workspace and the retrieved server version. For more information, see the Resolve Command.

Examples

The following example retrieves the latest version of 314.cs from the server. If you have pending changes against 314.cs, Team Foundation Server initiates the Resolve process that helps you decide how to handle conflicts.

C:\projects>tf get 314.cs

The following example retrieves version 8 of 1256.cs from the server.

Note

Using 1256.cs;8 is equivalent to using 1256.cs;C8. By default, the changeset version is used if you specify only a number after the semicolon.

C:\>tf get 1256.cs;8

The following example retrieves the latest versions of all uncloaked items from the server folder and subfolders to the C:\projects directory and creates local folders where they are required. For more information about how to cloak and uncloak folders, see Workfold Command.

C:\projects>tf get

The following examples provide alternative ways of retrieving the version of 1256.cs that was checked in with changeset 1999.

c:\projects>tf get /version:C1999 1256.cs

—or—

c:\projects>tf get 1256.cs;C1999

The following example retrieves the version of all uncloaked items from the server as they existed in the server when changeset 271 was created.

c:\projects>tf get /version:C271

The following example retrieves build42, labeled as “build42." This matches your workspace to the label as long as there are no pending changes. Any files not in the label are removed from the local disk.

c:\projects>tf get /version:Lbuild42

Security

To use the get command, you must have the Read permission set to Allow for every retrieved item and you must either own the destination workspace or have the global Administer workspaces permission. For more information, see Team Foundation Server Permissions.

See Also

Tasks

Walkthrough: Working with Team Foundation Source Control from Command Line
How to: Get the Source for your Team Project
How to: Cloak and Decloak Folders in a Workspace

Reference

Resolve Command
Merge Command
Checkout and Edit Commands
Checkin Command
Unshelve Command
Workfold Command

Other Resources

Tf Command-Line Utility Commands