> ## Documentation Index
> Fetch the complete documentation index at: https://code.storage/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# repo.listCommits()

> List commit history with optional branch filtering.

> [!WARNING]
>
> This page documents the earlier Code Storage SDKs: `@pierre/storage`, `pierre-storage`, and
> `code-storage-go`. New code uses the [Pierre SDK](https://code.storage/docs/sdks.md). To move code to the new SDK, use the
> [`pierre-migrate`
> skill](https://github.com/pierrecomputer/skills/tree/main/skills/pierre-migrate).

```typescript TypeScript theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
// List commits from default branch
const commits = await repo.listCommits();
console.log(commits.commits[0]?.parentShas);

// List commits from specific branch
const branchCommits = await repo.listCommits({
  branch: 'feature/new-auth',
  limit: 20,
});

// List commits from an ephemeral branch
const previewCommits = await repo.listCommits({
  branch: 'preview/pr-123',
  ephemeral: true,
});

const pathCommits = await repo.listCommits({
  branch: 'main',
  path: 'docs/guide.md',
});
```

```python Python theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
commits = await repo.list_commits(
    branch="feature/new-auth",
    limit=20,
)
for commit in commits["commits"]:
    print(commit["sha"], commit["parent_shas"])

# List commits from an ephemeral branch
preview_commits = await repo.list_commits(
    branch="preview/pr-123",
    ephemeral=True,
)

path_commits = await repo.list_commits(
    branch="main",
    path="docs/guide.md",
)
```

```go Go theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
// List commits from a branch
commits, err := repo.ListCommits(context.Background(), storage.ListCommitsOptions{
	Branch: "feature/new-auth",
	Limit:  20,
})
for _, commit := range commits.Commits {
	fmt.Println(commit.SHA, commit.ParentSHAs)
}

// List commits from an ephemeral branch
ephemeral := true
previewCommits, err := repo.ListCommits(context.Background(), storage.ListCommitsOptions{
	Branch:    "preview/pr-123",
	Ephemeral: &ephemeral,
})

pathCommits, err := repo.ListCommits(context.Background(), storage.ListCommitsOptions{
	Branch: "main",
	Path:   "docs/guide.md",
})
```

## Options

**branch** `string`

Branch name to list commits from. Defaults to the default branch.

**limit** `number`

Maximum number of commits to return

**cursor** `string`

Pagination cursor from a previous response

**ephemeral** `boolean`

Resolve `branch` against the ephemeral namespace instead of the default namespace (default:
`false`)

**path** `string`

Limit history to commits that touched a file or subtree.

## Response

**commits** `array`

List of commit objects.

**commit fields**

**commits\[].sha** `string`

Commit SHA. Go: `SHA`.

**commits\[].parentShas** `string[]`

Parent commit SHAs in Git parent order. Empty for root commits. Python: `parent_shas`; Go: `ParentSHAs`.

**commits\[].message** `string`

The subject line of the commit message: the first paragraph of the message as one line,
without the body and the trailers. [`getCommit()`](https://code.storage/docs/sdk/repos/commit-get) returns the full
message.

**commits\[].authorName** `string`

Author name. Python: `author_name`; Go: `AuthorName`.

**commits\[].authorEmail** `string`

Author email. Python: `author_email`; Go: `AuthorEmail`.

**commits\[].committerName** `string`

Committer name. Python: `committer_name`; Go: `CommitterName`.

**commits\[].committerEmail** `string`

Committer email. Python: `committer_email`; Go: `CommitterEmail`.

**commits\[].date** `Date | datetime | time.Time`

Parsed commit timestamp.

**commits\[].rawDate** `string`

RFC 3339 timestamp string as returned by the server. Python: `raw_date`; Go: `RawDate`.

**nextCursor** `string`

Cursor for the next page (absent when no more results). Python: `next_cursor`; Go: `NextCursor`.

**hasMore** `boolean`

Whether additional pages are available. Python: `has_more`; Go: `HasMore`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.