TFS : Destroy Command to Delete files & folders permanently

Files in the TFS server are not permanently deleted when you delete them because it is soft delete .They stay in TFS server and you can restore them.

Its good feature of TFS for recovering the files in case they are accidentally deleted  but due to this feature the used space continuously get accumulated as a result TFS server free memory continuously decreases .

I was looking for the option which can permanently destroy the files and I found a good tutorial here .

https://docs.microsoft.com/en-us/vsts/tfvc/destroy-command-team-foundation-version-control

I appreciate the tutorial but it took me many hours to actually write the correct command

For long time

I was getting error

Unable to determine the source control server.

and some time other errors

I want to write here the correct command and explain so that others dont have to struggle

The correct command is

tf vc destroy $”tfs path of the folder or file  /” /s:”web url of the collection”

For example tf vc destroy $”/Project or collection name/Deployments/” /s:”http://mytfs:8080/tfs/myCollection”

If want to destroy and clean at the same time then

tf destroy /i /startcleanup “$/<Project or collection name/folder name >” /s:”http://mytfs:8080/tfs/myCollection”

 

I ran command at

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>

It may work anywhere in command prompt for because this path may be added to environment variable.

 

Use information at the following link if you simply want to clean space on TFS Server

https://docs.microsoft.com/en-us/vsts/tfs-server/command-line/tfsdeleteproject-cmd

Share This: