Hi all guys,
today I discovered that when you delete a branch from the Team Explorer in Visual Studio, the branch is not really deleted, but you can ‘restore’ the deleted branch if needed.
Bye the way if you really want to delete a branch (maybe after some months after the ‘weak’ deletion) you can do it using Visual Studio Command Prompt Console.
First of all you can see all the deleted branches in your Team Explorer enabling the following flag in your Tools > Options > Source Control > Visual Studio Team Foundation Server:

image

If you really want to delete a branch you can execute the following command (from Visual Studio Command Prompt):

tf destroy $/MyProject/Main/Bin /collection:http://servername:8080/tfs/myproject
Do you want to destroy $/MyProject/Main/Bin and all of its children? (Yes/No) y
Destroyed: $/MyProject/Main/Bin;X3601
Destroyed: $/MyProject/Main/Bin/Native;X360

You can find additional documentation from Micsofot here and remark that you can use the /preview option for seeing which files will be permanently deleted. I suggest you to use output redirection in order to really check all files in the following way:

tf destroy $/MyProject/Main/Bin /collection:http://servername:8080/tfs/myproject /preview > c:\prova.txt

Additionally you can force tfs to clean all files of this branch from the DB after executing the command specifying the following option /startcleanup. By default, the clean-up is scheduled to run once each day.

Advertisements