Deleting a folder in TFS

2019-03-11 15:20发布

问题:

I created a folder in a TFS Project under workspace "CPortalWS". I deleted the workspace, but now I would like to delete the folder in the project and the delete option is not available.

I've tried to create a new workspace mapped to the project but I still don't get the option to delete.

Is this a bug in TFS? How can I delete the folder?

Any help would be appreciated.

回答1:

Deleting a folder in TFS is a little strange.

You have to:

  • Create a Workspace

  • Get the latest source for the folder (to your local machine)

  • Inside Source Explorer, delete the folder

  • Check in your changes (this is the step that deletes the folder in Source Control)



回答2:

only note that delete is not an actual delete. the folders/files are still there and kept in Version Control, for example for Undelete scenarios. You can see them and avail the undelete function if you go to "Tools > Options > Source Control > Visual Studio Team Foundation Server" and check "Show deleted items in the Source Control Explorer" and then right-click on one of the deleted folders.

so, if you want real delete, where the folder/files actually go away you need to use the Destroy Command which is only available from the command line, see link below

http://msdn.microsoft.com/en-us/library/bb386005.aspx



回答3:

When you delete in TFS, it does not remove it from TFS. It maintains a copy of the deleted files, even when you check in the deletion. This can cause some issues. To permanently delete from TFS, you need to issue a tfs destroy command.

To do this:

  1. Open a Visual Studio Command Prompt.
  2. Issue the following command: tf destroy $/SourceLocation/Folder. Where $/SourceLocation/Folder is the Source location of the deleted folder in TFS.

Please note: This command will also delete the file(s) from disk.



回答4:

I had a similar issue, where I had 1 folder which despite being deleted from Hard drive, was still showing as in Source Control (with a green + by the folder). It also showed me the content but if I tried to open any, an error message informed me the file wasn't there.

Clicking on any folder didn't show the delete button. I then realised that selecting a file did! If you don't have a file, create a text file and add it to the folder you want to delete (via Source Control). Click this file, note the delete shows. Select a folder and note that the delete disappears but only after half a second. This small delay is actually usable.

I clicked the file, so the delete button is enabled and hovered the mouse above the delete button. Using the keyboard, I did a CTRL + A and as soon as all files and folders were selected I clicked left mouse button. And it worked! Everything was removed, including (and this is the odd thing) the parent folder.



回答5:

Create a Workspace; and get latest on the base folder; Dont forget to cloak the relevant folders. If you are going to delete the subfolders then cloak all and get latest on the base folder. So you save a lot of time in pulling files.