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 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)] [/recursive] itemspec[;deletionID] [/login:username,[password]]
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 (Version Control).
Specifies a unique identifier that disambiguates multiple deleted items with the same name.
Provides a value to the /login option. You can specify a username value as either DOMAIN\UserName or UserName.
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.
Restores all files and subfolders from the specified directory.
Specifies the user name and password to authenticate the user with Visual Studio Team Foundation Server.
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.
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