Udostępnij za pośrednictwem


Undelete Command

The undelete command restores items that were previously deleted.

Note

The results of this command are not visible in other workspaces until you perform a check-in operation. For more information, see How to: Check In Pending Changes.

Required Permissions

To use the undelete command, you must have the Check out permission set to Allow. If you include the /lock option with a value other than none, you must have the Lock permission set to Allow. Additionally, you must own the workspace or have the global Administer workspaces permission set to Allow. For more information, see Team Foundation Server Permissions.

tf undelete [/noget] [/lock:(none|checkin|checkout)] [/newname:name] 
[/recursive] itemspec[;deletionID]

Parameters

Argument

Description

name

The user-provided value for the /newname option. You can specify either a local or server path.

itemspec

Identifies the file or folder to undelete. For more information about how Team Foundation parses itemspecs to determine which items are within scope, see Command-Line Syntax (Team System).

deletionID

Specifies a unique identifier that disambiguates multiple deleted items with the same name.

Option

Description

/noget

Restores the deleted item to your workspace and then, pending completion of a check-in operation, restores the item on the server but does not immediately retrieve a physical copy of the item to disk.

/lock

Prevents other users from checking in or checking out the specified files. For more information, see Understanding Lock Types.

Lock Options:

  • None

    Default. No lock is applied.

  • 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.

/newname

Renames the item when restoring it.

/recursive

Restores all files and subfolders from the specified directory.

Remarks

The Undelete command of the tf command-line feature schedules specified files or folders for restoration pending the completion of a check-in operation. It also retrieves the specified items from the server to the local disk unless you explicitly include the /noget option.

When files or folders that have the same name have been deleted from the same server folder, you must include a value for the deletionID parameter to indicate which of the deleted items that you want to restore. You can obtain a deletionID using the dir command.

To undelete an item into a server folder where an item with that same name already exists or is pending addition, you can use the /newname option to give the undeleted item a new name. You can undelete only one item at a time using the /newname option.

If you want to change the file after restoring it, you may check out the file for editing with the checkout command as usual.

When your itemspec specifies a folder, Team Foundation restores all its files and subfolders and the files they contain, by default. If you do not want to restore all the items in a folder, you must first undelete the folder and its items and then delete the items that you do not want to keep.

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

Examples

The following example restores 314.cs to the server folder from which 314.cs was deleted and retrieves a read-only copy of the latest version in the current workspace.

C:\projects>tf undelete c:\math\314.cs

The following example displays deletion IDs for all items on the server that have been deleted more than one time.

c:\projects>tf dir $/ /deleted
  • Sample output:

    $/projects/math/314.cs;X10
    $/projects/math/314.cs;X11
    

The following example restores the X11 version of 314.cs to the server folder from which the file was deleted and retrieves a read-only copy of the latest version in the current workspace.

c:\projects>tf undelete 314.cs;X11

See Also

Concepts

Pending Changes

Understanding Lock Types

Reference

Command-Line Syntax (Team System)

Rename Command (Team Foundation Version Control)

Delete Command

Dir Command

Other Resources

Tf Command-Line Utility Commands