How To Permanently Delete Files from TFS

Chuck Lafferty
Confident Coder
Published in
2 min readJun 19, 2016

--

  • *WARNING*** tf destory command permanently deletes files from TFS. Use with great caution. There is no recovery.

Your TFS repository can become quite messy with old deleted folders and files. The great thing about TFS is it will not permanently delete files. They will be stored in case you want to recover them. For those people who may run into TFS database disk-space concerns there is way to permanently delete TFS items. Take great caution as what i am about to tell you means the thing you destroy can not be recovered.

How to Permanently Delete Items in TFS

  1. The command to delete items in TFS is “tf destroy”. In order to run the command you must have project administrator privileges on your project. Get that permission first.
  2. Now you need to open VS Tools command prompt. Unfortunately Microsoft has made it hard to find in VS2015. Here is a post how to setup VS tools command prompt in visual studio Developer Command Prompt for Visual Studio
  3. Now that you have Visual Studio Tools setup open the VS tools command (If you did it the way of the tutorial suggests, open Visual Studio > Tools > Command Prompt) I called mine VS2015 Native Tools
  4. Here is the command to destroy a file permanently. Destroy Command (Team Foundation Version Control)
    tf destroy /i /startcleanup “$/<BranchName or FileName>” /collection:http://<TFS_URI>:8080/tfs/<CollectionName>

You can preview your changes by adding the /preview parameter.

I can’t stress enough to use caution. Triple check you are deleting the correct file or folder and, as a safeguard, use the /preview parameter first to verify you are not deleting the trunk of your project!

--

--