Skip to main content
Create a new commit that resets a branch back to a specific commit SHA.
POST /api/v1/repos/restore-commit
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/x-ndjson

{"metadata":{"target_branch":"main","target_commit_sha":"abc123...","commit_message":"Reset branch","author":{"name":"Docs Bot","email":"docs@example.com"}}}

Request Format

Send a single metadata object.

Metadata Fields

ParameterTypeDescription
target_branchRequiredBranch name to reset (no refs/ prefix).
target_commit_shaRequiredCommit SHA to reset the branch to.
authorRequiredObject with name and email.
expected_head_shaOptionalGuard to ensure the current tip matches before applying.
commit_messageOptionalCommit message for the restore commit.
committerOptionalObject with name and email.

JWT Requirements

  • The JWT must include the repository in the repo claim
  • Requires git:write scope

Response

{
  "commit": {
    "commit_sha": "def456...",
    "tree_sha": "7890ab...",
    "target_branch": "main",
    "pack_bytes": 1234
  },
  "result": {
    "branch": "main",
    "old_sha": "abc123...",
    "new_sha": "def456...",
    "success": true,
    "status": "ok",
    "message": ""
  }
}

Error Responses

StatusDescription
400 Bad RequestMissing or invalid fields
401 UnauthorizedInvalid JWT or missing authorization header
403 ForbiddenMissing git:write scope
404 Not FoundRepository or commit not found
409 ConflictExpected head SHA does not match