TFS – Deleting Folders without “Getting Latest Version”

I find it such a pain in TFS (2012 & Others) to have to grab the latest version of a folder in order to delete the folder. The larger issue comes into play if you have a large set of feature or release branches that you want to get rid of, but can’t afford to spend the 1-2 hours downloading them first.

One approach that I’ve found is pretty simple and straightforward, is to use the command line “TF get” to download the latest version of the folder, except not recursively – so just the top level; which you can imagine is %1000 faster than downloading everything.

Here is my scenario: I have a Releases folder with a lot of old version numbers and branching strategies. Essentially I want to delete everything not highlighted in the red box:


These are fairly large branches that would likely take me 2 hours to download everything (slow connection from the office).

Instead, if you hop on over, and use the “Developer Command Prompt for VS2012” (or similar version), you can specify to download only the folders:

  1. First, navigate via command line to the matching local directory on your physical machine where your workspace folder is mapped that you want to delete (using standard change directory command line “cd c:Development”).
  2. Run the following command: “tf get $/RootProject/PathToFolder/FolderToDelete”

In my scenario I specified to download the “Releases” folder, which would get latest on folders only one level below it: “tf get $/Development/Application/Releases”, and the command line shows each folder retrieved within seconds:

Capture23. Now head back to Visual Studio Source Control Explorer, and you’ll be able to delete any of these folders through the UI. I can highlight multiple and delete them all at once and check-in the deletes with ease.

Leave a Reply