Commit repository files atomically
gh_commit_filesCreate or replace repository files in a single GitHub commit and conditionally advance a branch only when its current SHA matches the expected head. Prevents overwriting concurrent changes.
Instructions
Destructive write: create or replace bounded UTF-8 file contents in one Git commit and conditionally advance exactly one existing branch only when its head matches expected_head_sha. Ordinary write authorization and the content-commit fine gate are required. The branch advance uses one exact compare-and-swap attempt followed by authoritative ref readback; it cannot delete files, force-update the ref, or blindly retry an ambiguous update.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | GitHub repository name without the owner prefix. | |
| files | Yes | Complete UTF-8 file replacements for the atomic commit. | |
| owner | Yes | GitHub repository owner or organization login. | |
| branch | Yes | Existing branch to advance conditionally. | |
| commit_message | Yes | Git commit message. | |
| expected_head_sha | Yes | Exact branch head SHA required before the write. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | ||
| branch | Yes | ||
| message | Yes | ||
| warning | No | ||
| tree_sha | No | ||
| commit_sha | No | ||
| request_id | No | ||
| ref_updated | No | ||
| files_committed | No | ||
| write_completed | Yes | ||
| observed_head_sha | No | ||
| previous_head_sha | Yes | ||
| readback_attempts | No | ||
| readback_completed | Yes | ||
| precondition_checked | Yes | ||
| state_matches_requested | Yes |