Delete Command (Team Foundation Source Control)

Removes files and folders from the Team Foundation source control server and deletes them from the disk.

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.

tf delete [/lock:(none|checkin|checkout)] [/recursive] itemspec

Parameters

Argument Description

itemspec

Identifies the file or folder to delete from the Team Foundation source control server. For more information about how Team Foundation parses itemspecs to determine which items are within scope, see Command-Line Options.

Option Description

/lock

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

Lock Options:

  • None

    Default. No lock is applied. If a lock exists on the specified file, this option removes it.

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

/recursive

Deletes all files and/or folders and subfolders from the specified directory.

  • tf delete folder1\folder2 /recursive (where folder1\folder2 exists and is a directory) deletes all the files and subdirectories contained by folder1\folder2 and folder1\folder2 itself.

  • tf delete folder1\folder2\filespec* /recursive deletes all files and subdirectories matching filespec contained in folder1\folder2 and each of its subdirectories, as well as all files and subdirectories contained within any such matching directory.

    For example, in a workspace containing:

    Folder1\AVeryLongDirectoryName (with some files inside) and Folder1\Folder2\AVeryImportantFile.txt

    tf delete 'Folder1\AVer*' /recursive

    deletes folder1\folder2\NeverDelete\AVeryImportantFile.txt because it matches the wildcard character.

Remarks

The delete command records a pending change of type "delete" in your workspace for the items that you have specified. When you commit a pending change of type "delete" to the Team Foundation source control server by using the checkin command, Team Foundation removes the item from the Team Foundation source control server but does not delete it permanently. You can locate deleted items in the Team Foundation source control server by using the Dir Command and you can restore deleted items using the Undelete Command.

The delete command adds specified items to the list of pending changes in your workspace. To commit a pending deletion to the Team Foundation source control server and complete the delete operation, you must check in the pending change. For more information, see How to: Check In Pending Changes.

If you have deleted an item in your workspace but have not checked in the change, you can restore the item to your workspace and remove the deletion from your list of pending changes using the Undo Command.

You cannot delete an item for which another pending change exists. For example, a checked out file cannot be deleted. To delete such items, you must undo the current pending change using the undo command.

When you check in a pending deletion, Team Foundation marks the file as deleted in the Team Foundation source control server. Subsequently running a get of the item from other workspaces (either by you or other users) deletes the item from those workspaces.

When your itemspec specifies a folder, Team Foundation deletes all its files and subfolders and the files they contain, by default.

Examples

The following example deletes 314.cs on disk in the specified local workspace folder and then, when you check in the change, removes 314.c from the source control system non-permanently.

c:\projects>tf delete 314.cs

Security

To use the delete 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.

See Also

Tasks

Walkthrough: Working with Team Foundation Source Control from Command Line
How to: Move, Rename, and Delete Source-Controlled Files and Folders

Reference

Undelete Command
Undo Command
Dir Command

Other Resources

Tf Command-Line Utility Commands