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

target_branch
string
required
Branch name to reset (no refs/ prefix).
target_commit_sha
string
required
Commit SHA to reset the branch to.
author
string
required
Object with name and email.
expected_head_sha
string
Guard to ensure the current tip matches before applying.
commit_message
string
Commit message for the restore commit.
committer
string
Object 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

400 Bad Request
string
Missing or invalid fields
401 Unauthorized
string
Invalid JWT or missing authorization header
403 Forbidden
string
Missing git:write scope
404 Not Found
string
Repository or commit not found
409 Conflict
string
Expected head SHA does not match