0

Some of my feature/user branches got deleted by someone in VSO as part of repository cleanup by mistakenly.

IS there a way to retain what branches deleted by whom and also is there any way to retain the deleted branch from vso git repository

Mathiyazhagan
  • 1,389
  • 3
  • 13
  • 37
  • 1/2 of your answer is here, https://stackoverflow.com/questions/3640764/can-i-recover-a-branch-after-its-deletion-in-git – raterus Jan 05 '18 at 14:50
  • Did the answer help you solve the problem? If yes, you can mark it as answer. And it will also benefit others who have similar questions. – Marina Liu Jan 18 '18 at 08:34

1 Answers1

0

Yes, you can restore the deleted branches and find who and when deleted the branches in VSTS.

  • First, you should get the deleted branch names so that you can restore them in VSTS.

    In your local repo (hasn't used git fetch after the branches deleted), use git branch -r, it will list all the remote branches. Then you can compare with the branches listed in VSTS, the branches show in local repo but not show in VSTS are the deleted branches.

  • Then get the deleted branches’ info and restore them.

    To restore a deleted branch (such as stage branch), you can follow below steps:

    In VSTS Code Tab -> branches (https://account.visualstudio.com/project/_git/repo/branches) -> search a deleted branch by name (such as stage) -> Then there will show No branches match the filter: stage -> open the link Search for exact in deleted branches -> it will list the extact match deleted branch and the detail information -> restore branch by clicking button.

    enter image description here

    enter image description here

    enter image description here

And you can also refer the document Restore a deleted Git branch from the web portal.

Besides, you can also restore the deleted branches in local repo ((hasn't executed git fetch after the branches deleted) by:

git checkout <a deleted branch in remote>
git push -u origin branchname
Marina Liu
  • 36,876
  • 5
  • 61
  • 74