user595010
user595010

Reputation:

Delete TFS branch without downloading it

I am trying to delete a branch that has not been downloaded into my workspace via following command.

tf delete /lock:checkout /recursive $/TfsServerName/TfsFolder/Branch

I get following error message:

No matching items found in $/TfsServerName/TfsFolder/Branch in your workspace.

Is there a way to delete a TFS branch without actually downloading it?

Upvotes: 37

Views: 14113

Answers (4)

Andre Pena
Andre Pena

Reputation: 59446

In the Source Control Explorer, if you simply map the branch to a local path and hit OK, it will enable the "delete dropdown".

Upvotes: 1

Erik
Erik

Reputation: 51

In the Source Control Explorer you can get the latest version of a branch then cancel it as soon as it starts downloading. That will un-ghost the branch allowing you to delete it through the interface. You'll also have to delete the few files that were downloaded to your local work space. It's a total hack but it's really quick and easy.

Upvotes: 5

Tim Abell
Tim Abell

Reputation: 11901

Make sure the folder above the branch is mapped to the filesystem, then:

  1. Open up Visual Studio's "Developer Command Prompt"
  2. cd (change directory) into the folder above the branch
  3. and run the following:

tf get .
tf delete /recursive branch-folder
tf checkin

This will do a non-recursive get, mark the whole branch/folder for deletion, then prompt you to enter a message and check in the change.

Should work with VS2012-2015 & TFS 2010 to current. Also tested with Visual Studio Team Services hosted TFS (as of 25th Feb 2016)


With VS2012 / TFS server 2010, the delete command needs /recursive

Upvotes: 27

Ewald Hofman
Ewald Hofman

Reputation: 12668

you can do a non-recurisve get of only the folder with the "tf get" command. I am not aware that you can delete it when you don't have a local copy of the folder.

Upvotes: 30

Related Questions