> For the complete documentation index, see [llms.txt](https://agpt.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agpt.co/docs/integrations/block-integrations/commits.md).

# GitHub Commits

Blocks for listing commit history and creating multi-file commits in GitHub repositories.

## Github List Commits

### What it is

This block lists commits on a branch in a GitHub repository.

### How it works

This block fetches commits from a GitHub repository using the Commits API. You can filter by branch name and control the number of results with pagination parameters.

Each commit entry includes the SHA, commit message, author name, date, and a URL to view the commit on GitHub.

### Inputs

| Input     | Description                                                                                              | Type | Required |
| --------- | -------------------------------------------------------------------------------------------------------- | ---- | -------- |
| repo\_url | URL of the GitHub repository                                                                             | str  | Yes      |
| branch    | Branch name to list commits from                                                                         | str  | No       |
| limit     | Maximum number of commits to fetch                                                                       | int  | No       |
| per\_page | \[Legacy] Number of commits to return per page (max 100). If set (or `page` is set), `limit` is ignored. | int  | No       |
| page      | \[Legacy] Page number for pagination. If set (or `per_page` is set), `limit` is ignored.                 | int  | No       |
| path      | Only include commits that touch this file or directory path                                              | str  | No       |
| author    | Only include commits authored by this user (GitHub username or email address)                            | str  | No       |
| committer | Only include commits committed by this user (GitHub username or email address)                           | str  | No       |
| since     | Only include commits after the given ISO 8601 timestamp                                                  | str  | No       |
| until     | Only include commits before the given ISO 8601 timestamp                                                 | str  | No       |

### Outputs

| Output  | Description                             | Type              |
| ------- | --------------------------------------- | ----------------- |
| error   | Error message if listing commits failed | str               |
| commit  | A commit with its details               | Commit            |
| commits | List of commits with their details      | List\[CommitItem] |

### Possible use case

**Activity Monitoring**: Track recent commits on a branch to monitor development progress.

**Changelog Generation**: Retrieve commit messages to automatically compile release notes or changelogs.

**Audit Trail**: List commits to review who made changes and when for compliance purposes.

***

## Github Multi File Commit

### What it is

This block creates a single commit with multiple file upsert/delete operations using the Git Trees API.

### How it works

This block creates a single atomic commit that can add, update, or delete multiple files at once using the low-level Git Trees API. It fetches the latest commit SHA on the target branch, creates blobs for each upserted file concurrently, builds a new tree with all file operations, creates a commit pointing to that tree, and updates the branch reference.

For delete operations, a null SHA is set in the tree entry to remove the file. This approach is more efficient than making separate commits per file and ensures all changes land in a single commit.

### Inputs

| Input           | Description                                                                                                                           | Type                      | Required |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -------- |
| repo\_url       | URL of the GitHub repository                                                                                                          | str                       | Yes      |
| branch          | Branch to commit to                                                                                                                   | str                       | Yes      |
| commit\_message | Commit message                                                                                                                        | str                       | Yes      |
| files           | List of file operations. Each item has: 'path' (file path), 'content' (file content, ignored for delete), 'operation' (upsert/delete) | List\[FileOperationInput] | Yes      |

### Outputs

| Output | Description                        | Type |
| ------ | ---------------------------------- | ---- |
| error  | Error message if the commit failed | str  |
| sha    | SHA of the new commit              | str  |
| url    | URL of the new commit              | str  |

### Possible use case

**Automated Code Generation**: Commit generated code, configuration files, and scaffolding in a single atomic operation.

**Batch File Updates**: Update multiple configuration or documentation files across a repository in one commit.

**Cleanup Operations**: Delete obsolete files while adding replacements in a single commit to keep history clean.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://agpt.co/docs/integrations/block-integrations/commits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
