TFS: Restore deleted folders and items

Tfs

Tfs Problem Overview


I deleted some files and some folders in TFS. Many check in's later I found out that I need the deleted functionality back in my project.

How can I restore the deleted files and folders?

Tfs Solutions


Solution 1 - Tfs

In Team Explorer (in Visual Studio): Tools | Options | Source Control | Visual Studio Team Foundation Server and select Show Deleted Items...

Then in source control explorer you'll see the items greyed out. You can right click on them and Undelete. (This option will only be available if they, after the undelete, will be included in your current workspace).

NB. in newer versions of Visual Studio (eg. 2013) there is now a button to switch on display of deleted items in the Source Control Explorer's toolbar. Its the second button (here with the VS dark theme):

enter image description here

Alternatively using the TFS PowerToys you can look at history and right click to select "Rollback Entire Changeset": this will create pending changes to revert the changes of the selected changeset.

Edit: Added paragraph on newer versions of VS.

Solution 2 - Tfs

Assuming you successfully undelete as per @Richard's answer, there might still be an issue with the item appearing in Solution Explorer (at least it was for me using Visual Studio 2015). That is to say, the file is restored on your hard drive, in the proper place in your project's folder structure--but it's not showing in VS.

To resolve this, click the Show All Files button in Solution Explorer:

enter image description here

You will see your file, in a ghostly white icon. Right-click on it and select "Include in project". Save and check-in changes. You are back in business.

Solution 3 - Tfs

Recently I faced this issue, accidentally I deleted some classes which weren't checked in, I searched the name of the classes in my project directory (I was working on D365 project there is a bin folder in C:\AOSService\PackagesLocalDirectory\bin\XppSource) and saw that in the bin folder they were existed so I created new classes with the same name and copy the logic. Also I should mention that no file was in recycle bin.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhwcverweView Question on Stackoverflow
Solution 1 - TfsRichardView Answer on Stackoverflow
Solution 2 - TfsBCAView Answer on Stackoverflow
Solution 3 - TfsNastaran HakimiView Answer on Stackoverflow