git.commits.restoreRestore a branch's files to an earlier commit, in one new commit
History is kept: the new commit sits on top of the branch and holds exactly the files of `commit`, so files added since are deleted and files deleted since come back. A retry is safe: when the branch already holds those files the answer is 200 with `created: false`, even if `expectedOid` is now stale.
Request syntax
POST /git/api/repositories/{repoId}/restore
{
"branch": "string",
"commit": "string",
"message": "string",
"author": "object",
"expectedOid": "string"
}Path parameters
repoIdRequiredstring
Constraints: uuid
Request body
branchRequiredstring
The branch whose files to restore; it must exist
Constraints: 1-255 chars
commitRequiredstring
The commit whose files the branch gets: a full commit id (best, a retry then means the same commit), a branch, a tag, or an abbreviated id of at least 7 characters. It must be reachable from a branch or tag of this repository
Constraints: 1-255 chars
messageOptionalstring
The commit message; `Restore to <short id>: <its subject>` when absent
Constraints: 1-2000 chars
authorOptionalobject
Record someone else as the author, for a tool committing on behalf of its user; the committer is always the caller. The caller when absent
Constraints: JSON
expectedOidOptionalstring
Refuse (409) unless the branch is still at this commit, so a restore cannot overwrite a newer save
Constraints: /^[0-9a-f]{40}$/
Response
200 with `commitOid`, `restoredFrom` and `created` (false when the branch already held those files). 404 for an unknown commit, 422 for one that is not a commit or an ambiguous abbreviation, 409 when the branch moved past `expectedOid`, does not exist, or a protection rule says no.
A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.
Fields of data
commitOidAlwaysstring
The tip of the branch: the new commit, or the existing tip when nothing had to changerestoredFromAlwaysstring
The full id of the commit whose files the branch now holdscreatedAlwaysboolean
false when the branch already held exactly those files, so no commit was made
Checked against the handlers: every route test validates their answers against this schema.
Errors
- 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
- 401No credentials, or an access key that is unknown, revoked or expired.
- 403The caller's policies do not allow git:PushRepository on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
- 404The resource does not exist in your organization.
Examples
The required parameters only, with example values. Replace id and the other placeholders with your own.
dcloud git commits restore repoId --branch example --commit examplecurl -X POST "https://console.platform.deutschecloud.app/git/api/repositories/repoId/restore" \
-H "Authorization: EWS-ACCESS-KEY $ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{"branch":"example","commit":"example"}'import { DcloudClient } from '@dcloud/sdk';
const client = new DcloudClient();
const result = await client.git.commits.restore({ repoId: "repoId", branch: "example", commit: "example" });from dcloud import Client
client = Client()
result = client.git.commits.restore(repo_id="repoId", branch="example", commit="example")Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_git_commits_restore.