# Destroy Command (Team Foundation Version Control)

Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018

Visual Studio 2022 | Visual Studio 2019 | Visual Studio 2017 | Visual Studio 2015 | Visual Studio 2013

Use the tf destroy command to destroy, or permanently delete, version-controlled files from Team Foundation version control.

The destroy action cannot be reversed. You must not destroy files that are still needed. Sometimes you have to clean up version control systems. For example, if some files are infected with a computer virus, you have to remove them permanently from version control.

Before you run tf destroy without the /keephistory option, we recommend that you first delete the files you want to destroy. For more information, see Delete Files and Folders from Version Control.

After you delete the files you can synchronize the Team Foundation warehouse. Otherwise, the warehouse will not be synchronized with the destroyed items.

## Prerequisites

To use the destroy command, you must belong to the Team Foundation Administrators security group. For more information, see Default TFVC permissions.

## Syntax

tf destroy [/keephistory] <itemspec1>[;<versionspec>][<itemspec2>...<itemspecN>]


## Parameters

### Argument

Argument

Description

itemspec1 [itemspec2...itemspecN]

Destroyed: $/Test1/MyProject/MyProject/Program.cs However, the file is actually not destroyed because you used the /preview option. For more information on how to find the tf command-line utility, see Use Team Foundation version control commands. ### Effects of /keephistory on Other Version Control Operations If you specify the /keephistory option to retain the history of destroyed files, the files are treated as destroyed by the following Team Foundation version control operations: • Change content If you try to change the content of a destroyed file, for example edit or branch, the system issues an error message that states the content has been destroyed. • Branch, merge, or unshelve If you try to branch, merge, or unshelve destroyed items, the system issues an error message that states the content of the items has been destroyed. ### Destroying Previously Deleted Items If an item has already been deleted, a deletion ID is attached to it and results in a filename change. Code Search does not handle TF DESTROY notifications and so using TF DESTROY for TFVC repos will not automatically delete files in the Search index. As a result, these files appear in the code search results. To avoid these ghost files scenario, users are recommended to delete files before TF DESTROY operation. ## Examples ### Description The following example permanently deletes the file a.cs. ### Code C:\pi\ws1>tf destroy$/proj/pi/a.cs


### Description

The following example deletes a folder, aFolder, type at the command line:

C:\tf delete $/MyTeamProject/aFolder  ### Description To destroy the deleted item, aFolder, you must type at the command line: ### Code tf destroy$/MyTeamProject/sFolder;x123


Where x123 is the deletion ID.