10

I have accidentally deleted a Wiki-page from our repository in Azure DevOps. (How) can I recover it?

ScottWelker
  • 1,701
  • 17
  • 30
Mohammad
  • 1,498
  • 2
  • 12
  • 15
  • Hi again, I have just recently been told from Microsoft support team that the deleted page cannot be restored since it is a project wiki (as in contrast to code wiki). – Mohammad Jun 12 '20 at 19:21

4 Answers4

7

That is not an option for us, since we will loose many changes that were made after the last version no. up until the date I accidentally deleted the wiki page.

You can choose Clone wiki to download the wiki repo to local machine.

enter image description here

Then use git commands(git revert or what) locally to get the deleted page, once you find the deleted page, publish it and add it back to Wiki page as a new commit.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • reverting does not bring back the deleted wiki page – Mohammad Jun 02 '20 at 10:22
  • In my local machine it do bring back the deleted page to me. For me i delete the page in last commit, so `git revert HEAD` easily bring back the page. If you delete the page in a very old commit, you may need to use git revert commitid or other git commands. – LoLance Jun 02 '20 at 10:34
  • @Mohammad Revert is never the only way you can do, check [this](https://stackoverflow.com/a/30875442/10910450). My answer is actually talking about that we can download the repo locally and do whatever we can to get the deleted page, which avoids affecting the wiki repo on cloud... Just choose suitable git commands depending on your scenario, if the deleted page is once committed, then we should get it via git commands. – LoLance Jun 02 '20 at 10:41
  • I'm unfortunately not able to make it work for me using above instructions. – Mohammad Jun 03 '20 at 14:15
  • You can just use the URL from `Clone wiki` to navigate to it and use the UI to revert whatever commit you want to revert. See my answer :) – Tatiana Racheva Oct 16 '20 at 04:08
5

I was just able to do this without too much fanfare. The resource that was helpful was this VS community topic. There is an answer that provides a solution that doesn't require you to clone the repo.

The key insight is that you can navigate to the Azure DevOps repo UI for the Git repo that's backing the wiki. The solution author says that the shape of the URL is something like https://dev.azure.com/<organization-name>/<project-name>/_git/<wiki-name>.wiki. This didn't quite work for me because we have a different URL scheme in our organization, but I was able to figure it out after a little trial and error. I later saw that you can get the URL by using the Clone Repo UI in the wiki - it gives you the URL, so you can just copy it and navigate to it.

Anyway, the steps were:

  1. Figure out the URL of the git repo that backs the wiki
  2. Navigate to the revision history for the entire wiki
    • the current UI shows you the Contents tab by default - switch to History
  3. Scroll until you find the commits that deleted the pages you want to restore
    • it's one of those list views that populate themselves as you scroll, so you won't be able to use the browser page search efficiently, unfortunately
  4. Revert the commits
    • In my case, this required clicking on them and creating pull requests to revert, but I was able to merge them myself without involving code reviewers. YMMV

All in all, not a wholly terrible experience, but completely undiscoverable.

Tatiana Racheva
  • 1,289
  • 1
  • 13
  • 31
2

Assuming you're managing a provisioned wiki (vs using published code as a wiki):

Look in the top-right corner for the vertical 3-dot menu, where there's an option to view revisions:

Hamburger menu to select revision history

Choose the revision you want to revert to (e.g. the one prior to deleting the needed wiki page), from the list (click on its version hash):

List of revisions and related hashes

From the revision details, select "Revert":

Option to revert to prior revision

At this point, your wiki should be at its prior state, and your wiki page should once again be available.

Note: If you're using published code as a wiki, you would recover/revert your changes as you would with any other code commit.

More details may be found here.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • That is not an option for us, since we will loose many changes that were made after the last version no. up until the date I accidentally deleted the wiki page. – Mohammad May 31 '20 at 14:42
  • You can also export the entire existing wiki as a repo. I can't confirm that it will have revision history (I'll leave that up to you to find out), but... it's the only other option I'm aware of. – David Makogon May 31 '20 at 18:00
0

I couldn't find a way to do this through the Azure DevOps web interface but you can restore the page by reverting the commit that deleted it if you clone the wiki locally.

  1. Clone the wiki to your computer - find the clone wiki option in the menu at the top of the left bar which shows the wiki contents, copy the URL and use to clone locally using your usual git client.
  2. Find the commit that deleted the page, the commit message will start with "Deleted page" then the name of the page you deleted.
  3. Restore the page and commit the change. There are various ways to do this - I reverted the commit, you could checkout the commit and copy the page out to make a new commit. You may get a merge conflict on '.order', I'm not sure what the best thing to do is but I kept the current version and haven't had any problems.
  4. Push the changes to Azure DevOps, refresh and you'll see the page has been restored.

This works even for Project Wikis. I wonder if Azure DevOps has added the functionality that enabled this since some of the other answers have been written.