---
title: "Commit branch to git"
method: POST
path: "/api/v1/models/{modelId}/git/commit"
tags: ["Models"]
---

# Commit branch to git

`POST /api/v1/models/{modelId}/git/commit`

Push the branch contents to git and create or update a pull request. The backend automatically detects whether the git branch already exists: if not, it creates a new git branch and opens a PR; if it does, it commits the latest model contents to the existing branch (updating the open PR).

## Path parameters

- `modelId` string, uuid, required — Model UUID

## Request body

- ModelsCommitBody
  - `allow_branch_exists` boolean — If true (default), the commit succeeds whether the git branch already exists or not. If false, the request fails when the git branch already exists — use this to ensure only new pull requests are created. Cannot be false when require_branch_exists is true.
  - `branch_id` string, uuid, required — UUID of the branch to commit.
  - `commit_message` string, required — Commit message for the git commit.
  - `require_branch_exists` boolean — If true, the request fails when the git branch does not already exist — use this to ensure only existing pull requests are updated. Defaults to false. Cannot be true when allow_branch_exists is false.

## Response `200`

Branch committed to git and pull request created or updated

- ModelsCommitResponse
  - `did_sync` boolean, required — Whether a sync operation was performed against git
  - `git_sha` string, nullable, required — The git SHA of the commit that was pushed (null if no commit was needed)
  - `in_sync` boolean, required — Whether the branch is in sync with git after the operation
  - `pr_url` string, nullable, required — The URL of the pull request (or PR creation page for newly-created PRs). May be null when the underlying git provider is not recognized.

## Other responses

- `400` — Invalid request body
- `401` — Authentication required
- `403` — Permission denied or git not configured
- `404` — Model or branch not found

---

[API](https://skmtc.net/omniapp/apis/omni-api.md) · [All operations](https://skmtc.net/omniapp/apis/omni-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/omniapp/omni-api/versions/de7cac8b5983/schema)
