---
title: "Commit files to a repository through one of your git connections"
method: POST
path: "/git-connections/{connection_id}/repositories/{owner}/{repo}/commits"
tags: ["Git Provider Connections"]
---

# Commit files to a repository through one of your git connections

`POST /git-connections/{connection_id}/repositories/{owner}/{repo}/commits`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/git-connections/{connection_id}/repositories/{owner}/{repo}/commits`
- Auth: HTTP bearer

Adds a commit on top of the branch with the files given, using the token
of a connection you own, so the push has exactly the access that token
has. History is never rewritten. Another user's connection answers 404.

## Path parameters

- `connection_id` integer, required
- `owner` string, required
- `repo` string, required

## Request body

- CommitFilesRequest: Request body for committing files to a repository.
  - `branch` string, nullable: Branch to commit to. Defaults to the repository's default branch; a branch that does not exist is created from the default branch.
  - `files` CommitFileRequest[], required: Files to add or overwrite (1-100, at most 5 MiB in total). Files not listed are left as they are.
    - `content` string, required
    - `encoding` 'utf8' | 'base64': How the `content` of a committed file is encoded.
    - `path` string, required: Path inside the repository, relative and without `..` or `.git` segments, e.g. `cmd/server/main.go`.
  - `message` string, required: Commit message (at most 500 bytes).

## Response `201`

Files committed

- CommitFilesResponse
  - `branch` string, required
  - `commit_sha` string, required
  - `connection_id` integer, required
  - `file_count` integer, required
  - `repository` string, required

## Other responses

- `400`: Invalid path (including one through a symlink tracked in the repository), branch, message or file content, or the connection is inactive
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Connection not found, or not owned by the caller
- `409`: Nothing to commit (the files already match the branch), or the remote rejected the push (protected branch, hook, non-fast-forward)
- `502`: The git provider failed the request
- `504`: The commit timed out; `push_may_have_completed` says whether the branch must be checked before retrying

## Changes

> 81 revisions in range; 1 not diffed.

- **2026-10-21** `ab6d5d19e930`: 2 info
  - added the non-success response with the status `409`
  - added the non-success response with the status `504`
- **2026-10-20** `79089e9f49ee`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/git-connections/:connection_id/repositories/:owner/:repo/commits/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) · [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) · [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/ab6d5d19e930?raw)
