TF Destroy! Deleting code from TFS

Setting up a application life cycle in Team Foundation Server isn’t without it’s drawbacks.  Sometimes the whole process is trial and error to find a plan that works for your team.  Even if you get that all figured out chances are that along the way you created branches you don’t need anymore, or you branched the wrong code set, or gave it the wrong name.  It can be one big source safe mess after awhile.  All you want to do is clean it up, but it seems getting rid of code is about as simple a bug fixing.

As it turns out there’s a command line option to DESTROY branches in Team Foundation Server.

I know, DESTROY, sounds ominous.  Like the robot from the Lost in Space movie.  “Destroy Jupiter 2! Destroy Robinson Family!  DESTROY! DESTROY! DESTROY!”

Still…we want it gone, right?

TF Destroy will allow you to remove the unwanted branch from TFS without having to Get Latest on the entire code set, check it in, delete it, and update.  With smaller code sets that’s not a problem, but if you have a lot of branches, or large branches, this process is cumbersome.

Step 1. Open a Visual Studio command prompt

Step 2. Navigate to the location of the code set (this might be optional.  skip it for now, but if you’re having trouble come back to this step)

Step 3. Enter the “tf Destroy” command

If your branch is in the root it’s as simple as: tf destroy $”<branch name>”

If your branch is below the root simply add the folder structure: tf destroy $”root/subfolder/MyBranch”

Possible errors:

If you run into any authentication errors check to make sure you are still connected to the Team Foundation Server in Visual Studio.

 

Other Resources:

Here’s a link to MSDN that includes the other TF commands that are available – TF LIBRARY

2 comments for “TF Destroy! Deleting code from TFS

  1. Craig Stinnette
    February 19, 2016 at 7:13 pm

    We have installed TFS Source Control Explorer Extension. With it, in the advanced menu comes the Destroy option. It is the full-power version of tf Destroy. It is available to everyone. Dire consequences looming. The server admin isn’t much help, how do we restrict the permission for the Destroy command to be only Team Server Admins?

    I can’t find this answer anywhere.

  2. April 27, 2016 at 1:48 pm

    Hi Craig, I apologize for not seeing this comment earlier. I haven’t used the TFS Source Control Explorer Extension yet. I’ll give it a try as soon as I can and let you know what I find. Is it possibly set from the Security tab of the TFS server control panel (web version)?

Leave a Reply