Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accidentally deleted branch from TFS - Undelete and Rollback not available?

I'm using Visual Studio 2015 and have deleted a branch from our TFS source control. Looking at other guides there's mention of being able to recover the branch by opening Source Control Explorer, right-click and select 'Undelete' or 'Rollback'. These options are not available

enter image description here

I have not got this branch mapped on any workspace. Clicking on 'Undo Pending Changes...' brings up a message saying there are no pending changes. How can I restore a branch on TFS? Is there a way I can enable Undelete or Rollback?

like image 738
Novastorm Avatar asked Jun 03 '16 09:06

Novastorm


People also ask

How do I recover an accidentally deleted branch?

A deleted Git branch can be restored at any time, regardless of when it was deleted. Open your repo on the web and select the Branches view. Search for the exact branch name using the Search all branches box in the upper right. Click the link to Search for exact match in deleted branches.

How do you undo a delete in TFS?

Restore an item deleted from the serverFrom the menu bar choose Tools, Options. On the Options dialog box, navigate to Source Control, Visual Studio Team Foundation Server. Select Show deleted items in the Source Control Explorer, and then choose OK.

What work is restored when the deleted branch is recovered?

What work is restored when the deleted branch is recovered? The files which were stashed and saved in the stash index list will be recovered back. Any untracked files will be lost. Also, it is a good idea to always stage and commit your work or stash them.


1 Answers

First, please make sure you or your teammates haven't destroyed this branch (After doing this, there is no way to recover it in TFS server).

If you delete this branch in Visual Studio,

To restore an item deleted from the server

From the menu bar choose Tools, Options.

On the Options dialog box, navigate to Source Control, Visual Studio Team Foundation Server.

Select Show deleted items in the Source Control Explorer, and then choose OK.

From the menu bar choose View, Other Windows, Source Control Explorer.

In Source Control Explorer, navigate to the folder that contains the item you want to restore.

Open the item’s context menu (select the item and right-click it) and then choose Undelete.

If you delete this branch from your dev machine outside of Visual Studio,

Please check the solution from MSDN link Delete or restore files and folders


Morever, you can also try to use the undelete command restores items that were previously deleted. For Example:

tf undelete [/noget] [/lock:(none|checkin|checkout)] 
[/recursive] itemspec[;deletionID] [/login:username,[password]]

Update:

Note: To be able to undelete a branch you must first map the parent folder/branch to your workspace. Now, the undelete option will be enable.

like image 59
PatrickLu-MSFT Avatar answered Sep 28 '22 06:09

PatrickLu-MSFT