# List commits

> A branch's commits, newest first (the default branch unless ref names a branch, tag or commit): each with its sha, message (why it was made: g1t's commit messages say), author (name as git wrote it, and username, the g1t account the author's address belongs to, when one does), authored_at and html_url.

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/repos/{owner}/{name}/commits</code></div>

`limit` is 30 unless you say, at most 100. With `path` (a file or directory), only the commits that changed it, newest first (its history: added, changed, removed), with `last_changed`, the newest of them, and `complete` false when a long history was not walked to its start in time.

With `path`, `last_changed` is the commit that last changed that file or directory. `author.username` is the g1t account the author's address belongs to, when one does; the address is never returned.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`repository`](/reference/mcp/#repository) with `action` `commits`, and the same inputs
- **Scope:** An access token needs [`code:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `ref` | string | No | A branch, tag or commit; the default branch when left out. |
| `path` | string | No | A file or directory, such as scripts/deploy/npm-ci.mjs: only the commits that changed it. |
| `limit` | integer | No | How many commits: 30 unless you say, at most 100. |

## Example request

```sh
curl "https://api.g1t.sh/repos/flagon-io/g1t/commits?path=scripts%2Fdeploy%2Fnpm-ci.mjs&limit=1" \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
{
  "repo": "flagon-io/g1t",
  "commits": [
    {
      "sha": "85c083a0e4b1d2c3f4a5b6c7d8e9f0a1b2c3d4e5",
      "message": "The runner's broker test reads the relayed answer's body as chunks.",
      "author": {
        "name": "Chase Pierce",
        "username": "syntaqx"
      },
      "authored_at": "2026-10-12T22:04:11Z",
      "parents": [
        "75c6704f2b1a3c4d5e6f708192a3b4c5d6e7f809"
      ],
      "html_url": "https://g1t.sh/flagon-io/g1t/commit/85c083a0e4b1d2c3f4a5b6c7d8e9f0a1b2c3d4e5"
    }
  ],
  "path": "scripts/deploy/npm-ci.mjs",
  "last_changed": {
    "sha": "5d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e",
    "message": "Installs in cloud jobs retry when npm's download breaks off.",
    "author": {
      "name": "Chase Pierce",
      "username": "syntaqx"
    },
    "authored_at": "2026-10-13T01:12:40Z",
    "parents": [
      "0a1b2c3d4e5f60718293a4b5c6d7e8f9a0b1c2d3"
    ],
    "html_url": "https://g1t.sh/flagon-io/g1t/commit/5d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e"
  }
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
