Recover the deleted VSTS Git Repository

This might be not as uncommon as deleting the VSTS account, but this is critically important to the end users. Up until now, there was no way to recover the deleted VSTS git repository. However, with the launch of new version of API,  there is now a way to recover them and keep our jobs for another day.

However, this functionality is not yet available for GUI lovers and for now, available at API level only.  In this blog post, we’ll learn how to restore a deleted git repository by using REST APIs inside postman tool. However, you can use any REST client for this purpose. 

For this post’s purpose, we have deleted repo named DatabaseProjectDemo from one of my personal projects named DatabaseProjectDemo as well.

First, we can get list of git repos in the recycle bin and  a bunch of other useful information like who deleted repo and when by making GET request to below API:

It should show us a response like below:

Get list of git repos from the recycle bin

Now, we need to note the value of id for the deleted repo. After this, we need to issue a PATCH request to below API:

and passing deleted value in the request body (More details here.)

We should see a response like below:

Recover deleted repo using PATCH request

If we now go to the Code section in the VSTS portal, we can see our deleted repo is now back:

View recovered repo in the VSTS



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s