Coregit
API Reference

Branches

Create, list, and manage branches through the API.

Create Branch

POST /v1/repos/:slug/branches
{
  "name": "feature-x",
  "from": "main"
}
  • name — Required. New branch name
  • from — Branch name to copy from (optional)
  • from_sha — Commit SHA to branch from (optional, use instead of from)

If neither from nor from_sha is provided, branches from the default branch.

List Branches

GET /v1/repos/:slug/branches

Response 200:

{
  "branches": [
    { "name": "main", "sha": "7f3b..." },
    { "name": "feature-x", "sha": "a1c2..." }
  ],
  "default_branch": "main"
}

Get Branch

GET /v1/repos/:slug/branches/:name

Returns the branch name and the SHA of its head commit.

Delete Branch

DELETE /v1/repos/:slug/branches/:name

You cannot delete the default branch.

Merge Branch

POST /v1/repos/:slug/branches/:name/merge

The :name in the URL is the source branch. The request body specifies the target:

{
  "target": "main"
}
  • target — Branch to merge into (optional, defaults to repo's default branch)
  • strategy — Merge strategy (optional, currently only fast-forward is supported)

Response 200:

{
  "merged": true,
  "sha": "7f3b...",
  "strategy": "fast-forward"
}

Returns 409 if the merge cannot be fast-forwarded.

On this page