> 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       |
| per\_page | Number of commits to return (max 100) | int  | No       |
| page      | Page number for pagination            | int  | 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
