Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020
If a user accidentally deleted a provisioned (project) or published (code) wiki, you can restore it. Although there are no options in the UI to delete a wiki, users might use the REST API to delete the Git repository associated with the wiki.
Note
Deleted repositories remain in the recycle bin for 30 days, after which they're permanently deleted and can't be restored.
Prerequisites
| Category | Requirements |
|---|---|
| Project access | Member of the project where the wiki is located. If you don't have access, request it from your project administrator. Anyone with access to the team project can view the wiki, including Stakeholders. |
| Permissions | - To add or edit wiki pages: Member of the Contributors group. - To publish code as wiki: Create Repository permission. By default, this permission is set for members of the Project Administrators group. |
| Access levels | At least Basic access. |
Restore a complete wiki
Wikis, both project and code, are stored as repositories in your project in Azure DevOps. Complete the following steps to restore a complete wiki with REST API.
Retrieve git repositories: List repositories.
Use THE
includeHidden=trueparameter to see the wiki repositories.GET https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/repositories?includeHidden=true&api-version=7.1-preview.1{ "id": "978e3886-64a8-4b6f-96da-6afc2936b04b", "name": "fabrikamfiber.wiki", "url": https://dev.azure.com/christiechurch/052a83ac-af70-4194-b53f-df073e5f1786/_apis/git/repositories/978e3886-64a8-4b6f-96da-6afc2936b04b, "project": { "id": "052a83ac-af70-4194-b53f-df073e5f1786", "name": "fabrikamfiber", "url": https://dev.azure.com/christiechurch/_apis/projects/052a83ac-af70-4194-b53f-df073e5f1786, "state": "wellFormed", "revision": 421800049, "visibility": "organization", "lastUpdateTime": "2023-07-18T12:25:29.3Z" }, "defaultBranch": "refs/heads/wikiMaster", "size": 193, "remoteUrl": https://christiechurch@dev.azure.com/christiechurch/fabrikamfiber/_git/fabrikamfiber.wiki, "sshUrl": git@ssh.dev.azure.com:v3/christiechurch/fabrikamfiber/fabrikamfiber.wiki, "webUrl": https://dev.azure.com/christiechurch/fabrikamfiber/_git/fabrikamfiber.wiki, "isDisabled": false, "isInMaintenance": false }Search the recycle bin for your repository.
GET https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/recycleBin/repositories?api-version=7.1-preview.1When you find your repository, often named as
.wiki, take note of the repo ID.{ "value": [ { "id": "978e3886-64a8-4b6f-96da-6afc2936b04b", "name": "fabrikamfiber.wiki", "project": { "id": "052a83ac-af70-4194-b53f-df073e5f1786", "name": "fabrikamfiber", "url": https://dev.azure.com/christiechurch/_apis/projects/052a83ac-af70-4194-b53f-df073e5f1786, "state": "wellFormed", "revision": 421800049, "visibility": "organization", "lastUpdateTime": "2023-07-18T12:25:29.3Z" }, "deletedBy": { "displayName": "Christie Church", "url": https://spsprodeus23.vssps.visualstudio.com/A1df9d653-bdfb-459b-a0c7-725052b2f944/_apis/Identities/0a0a4b55-9671-440d-87bf-26644f200d8a, "_links": { "avatar": { "href": https://dev.azure.com/christiechurch/_apis/GraphProfile/MemberAvatars/aad.MDY4MDk2OGQtYWU5OS03Y2M5LTgxZTEtNTBjMDk4ZTllZTlh } }, "id": "0a0a4b55-9671-440d-87bf-26644f200d8a", "uniqueName": christiechurch@fabrikam.com, "imageUrl": https://dev.azure.com/christiechurch/_api/_common/identityImage?id=0a0a4b55-9671-440d-87bf-26644f200d8a, "descriptor": "aad.MDY4MDk2OGQtYWU5OS03Y2M5LTgxZTEtNTBjMDk4ZTllZTlh" }, "createdDate": "2023-07-18T12:23:55.64Z", "deletedDate": "2023-07-18T12:41:38.737Z" } ], "count": 1 }Restore the wiki from the repository recycle bin.
PATCH https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/recycleBin/repositories/978e3886-64a8-4b6f-96da-6afc2936b04b?api-version=7.1-preview.1{ "deleted": false }
The repository contents restore. If the wiki UI doesn't reappear automatically, publish the restored repo as a wiki or create a wiki via the Wiki REST API to re-register it with the project.
Restore a wiki page
Go to the URL for your repo:
https://dev.azure.com/<OrgName>/<ProjectName>/_git/classicreleaseoption.wiki.Search for the history for the main branch,
wikiMain.Find and select the commit that has the deleted files.
Select
More actions, and then Revert.Create and complete a pull request.
Your wiki page restores.
Restore a wiki page with CLI
If you prefer command line options, do the following steps.
- Clone the wiki to your local machine.
- Search for the commit, which has the deleted the page.
- Check out the commit.
- Copy the page to make a new commit.
Your wiki page is restored.
Delete a repository
DELETE https://dev.azure.com/christiechurch/fabrikamfiber/_apis/git/repositories/052a83ac-af70-4194-b53f-df073e5f1786?api-version=7.1-preview.1
Reassociate a restored wiki
The recycle-bin restore recovers the Git repository (wiki pages and history) but doesn't always re-create the wiki registration or the file name association in the UI.
If the wiki doesn't appear after you restore the repo, you have two options:
Option 1: Republish via UI
- Go to Overview > Wiki in your project.
- If no wiki appears, select Publish code as wiki.
- Select the restored repository and branch (usually
wikiMaster). - Provide a wiki name and folder path if needed.
- Select Publish.
For detailed steps, see Publish a Git repository to a wiki.
Option 2: Recreate wiki registration with REST API
Create a new wiki using the Wikis - Create REST API:
POST https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis?api-version=7.1-preview.2Request body:
{ "type": "codeWiki", "name": "Fabrikam Fiber Wiki", "projectId": "052a83ac-af70-4194-b53f-df073e5f1786", "repositoryId": "978e3886-64a8-4b6f-96da-6afc2936b04b", "mappedPath": "/", "version": { "version": "wikiMaster" } }Replace the following values:
{organization}: Your Azure DevOps organization name{project}: Your project name or IDname: Display name for the wikiprojectId: Project ID from step 2repositoryId: Repository ID from step 2mappedPath: Root folder path (usually/)version: Branch name (usuallywikiMaster)
Verify the wiki registration by listing wikis using the Wikis - List REST API:
GET https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis?api-version=7.1-preview.2
Post-restoration verification
After using either option:
- Confirm that the repo and branches exist in your project in Repos.
- Verify the wiki appears in your project under Overview > Wiki.
- Check permissions, links, and any widgets that referenced the old wiki.
Note
- The recycle-bin and some wiki-registration APIs are preview and can change—test in a nonproduction organization and use the api-version documented for your environment.
- For project wikis (provisioned wikis), use
type: "projectWiki"instead of"codeWiki"in the REST API call and omit therepositoryIdandmappedPathproperties.