0
votes

Is there an example of using the Azure Devops REST API DELETE to delete a single commit? I see this in the documentation:

https://docs.microsoft.com/en-us/rest/api/azure/devops/wiki/pages/delete%20page?view=azure-devops-rest-6.0

DELETE

https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis/{wikiIdentifier}/pages?path={path}&comment={comment}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}&versionDescriptor.versionType={versionDescriptor.versionType}&api-version=6.0

However, when I try to execute this against devops using postman I get this error:

{
    "$id": "1",
    "innerException": null,
    "message": "The version '{0}' either is invalid or does not exist.\r\nParameter name: versionDescriptor",
    "typeName": "Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer",
    "typeKey": "InvalidArgumentValueException",
    "errorCode": 0,
    "eventId": 0
}

I'm using the ID displayed in local history as the version (IE: "2e45375d"), and am using "commit" as version type, and am using "previousChange" as version option.

I am able to use the REST API to delete the entire page, however I would like to be able to delete specific commits.

2
This is an endpoint to remove wiki page, not commit.Krzysztof Madej

2 Answers

0
votes

You can't do that over REST API endpoint. Simply, there is no endpoint to delete commit. However you can rebase you repo to remove that commit. Please check this here on another SO question - How to really delete a commit on VSTS / Azure-devops

0
votes

We cannot delete a single commit via REST API, we could try to delete the commit via git cmd git rebase -i <commit>~1 or git rebase -p --onto SHA^ SHA, we could refer to this doc for more details.

This will start the rebase in interactive mode -i at the point just before the commit you want to whack. The editor will start up listing all of the commits since then. Delete the line containing the commit you want to obliterate and save the file. Rebase will do the rest of the work, deleting only that commit, and replaying all of the others back into the log.

In addition, the commit id(SHA) is 40 character instead of 2e45375d

We could copy the 40 character commit SHA by clicking on the Copy full SHA to clipboard button