The undelete command restores items that were previously deleted.
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.
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]
The user-provided value for the /newname option. You can specify either a local or server path.
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).
Specifies a unique identifier that disambiguates multiple deleted items with the same name.
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.
Prevents other users from checking in or checking out the specified files. For more information, see Understanding Lock Types.
Renames the item when restoring it.
Restores all files and subfolders from the specified directory.
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.
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
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