commits
Creates, updates, deletes, gets or lists a commits resource.
Overview
| Name | commits |
| Type | Resource |
| Id | github.repos.commits |
Fields
The following fields are returned by SELECT queries:
- get_commit
- compare_commits
- list_commits
Response
| Name | Datatype | Description |
|---|---|---|
node_id | string | (example: MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==) |
author | object | A GitHub user. (title: Simple User) |
comments_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments) |
commit | object | |
committer | object | A GitHub user. (title: Simple User) |
files | array | |
html_url | string (uri) | (example: https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e) |
parents | array | |
sha | string | (example: 6dcb09b5b57875f334f61aebed695e2e4193db5e) |
stats | object | |
url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e) |
Response
| Name | Datatype | Description |
|---|---|---|
ahead_by | integer | |
base_commit | object | Commit (title: Commit) |
behind_by | integer | |
commits | array | |
diff_url | string (uri) | (example: https://github.com/octocat/Hello-World/compare/master...topic.diff) |
files | array | |
html_url | string (uri) | (example: https://github.com/octocat/Hello-World/compare/master...topic) |
merge_base_commit | object | Commit (title: Commit) |
patch_url | string (uri) | (example: https://github.com/octocat/Hello-World/compare/master...topic.patch) |
permalink_url | string (uri) | (example: https://github.com/octocat/Hello-World/compare/octocat:bbcd538c8e72b8c175046e27cc8f907076331401...octocat:0328041d1152db8ae77652d1618a02e57f745f17) |
status | string | (diverged, ahead, behind, identical) (example: ahead) |
total_commits | integer | |
url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/compare/master...topic) |
Response
| Name | Datatype | Description |
|---|---|---|
node_id | string | (example: MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==) |
author | object | A GitHub user. (title: Simple User) |
comments_url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments) |
commit | object | |
committer | object | A GitHub user. (title: Simple User) |
files | array | |
html_url | string (uri) | (example: https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e) |
parents | array | |
sha | string | (example: 6dcb09b5b57875f334f61aebed695e2e4193db5e) |
stats | object | |
url | string (uri) | (example: https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_commit | select | owner, repo, ref | page, per_page | Returns the contents of a single commit reference. You must have read access for the repository to use this endpoint.> [!NOTE] > If there are more than 300 files in the commit diff and the default JSON media type is requested, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing. This endpoint supports the following custom media types. For more information, see "Media types." Pagination query parameters are not supported for these media types. - application/vnd.github.diff: Returns the diff of the commit. Larger diffs may time out and return a 5xx status code.- application/vnd.github.patch: Returns the patch of the commit. Diffs with binary data will have no patch property. Larger diffs may time out and return a 5xx status code.- application/vnd.github.sha: Returns the commit's SHA-1 hash. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag.Signature verification object The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:| Name | Type | Description | | ---- | ---- | ----------- | | verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. || reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. || signature | string | The signature that was extracted from the commit. || payload | string | The value that was signed. || verified_at | string | The date the signature was verified by GitHub. |These are the possible values for reason in the verification object:| Value | Description | | ----- | ----------- | | expired_key | The key that made the signature is expired. || not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. || gpgverify_error | There was an error communicating with the signature verification service. || gpgverify_unavailable | The signature verification service is currently unavailable. || unsigned | The object does not include a signature. || unknown_signature_type | A non-PGP signature was found in the commit. || no_user | No user was associated with the committer email address in the commit. || unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. || bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. || unknown_key | The key that made the signature has not been registered with any user's account. || malformed_signature | There was an error parsing the signature. || invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. || valid | None of the above errors applied, so the signature is considered to be verified. | |
compare_commits | select | owner, repo, basehead | page, per_page | Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "Understanding connections between repositories." This endpoint is equivalent to running the git log BASE..HEAD command, but it returns commits in a different order. The git log BASE..HEAD command returns commits in reverse chronological order, whereas the API returns commits in chronological order.This endpoint supports the following custom media types. For more information, see "Media types." - application/vnd.github.diff: Returns the diff of the commit.- application/vnd.github.patch: Returns the patch of the commit. Diffs with binary data will have no patch property.The API response includes details about the files that were changed between the two commits. This includes the status of the change (if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a renamed status have a previous_filename field showing the previous filename of the file, and files with a modified status have a patch field showing the changes made to the file.When calling this endpoint without any paging parameter ( per_page or page), the returned list is limited to 250 commits, and the last commit in the list is the most recent of the entire comparison.Working with large comparisons To process a response with a large number of commits, use a query parameter ( per_page or page) to paginate the results. When using pagination:- The list of changed files is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison. - The results are returned in chronological order, but the last commit in the returned list may not be the most recent one in the entire set if there are more pages of results. For more information on working with pagination, see "Using pagination in the REST API." Signature verification object The response will include a verification object that describes the result of verifying the commit's signature. The verification object includes the following fields:| Name | Type | Description | | ---- | ---- | ----------- | | verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. || reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. || signature | string | The signature that was extracted from the commit. || payload | string | The value that was signed. || verified_at | string | The date the signature was verified by GitHub. |These are the possible values for reason in the verification object:| Value | Description | | ----- | ----------- | | expired_key | The key that made the signature is expired. || not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. || gpgverify_error | There was an error communicating with the signature verification service. || gpgverify_unavailable | The signature verification service is currently unavailable. || unsigned | The object does not include a signature. || unknown_signature_type | A non-PGP signature was found in the commit. || no_user | No user was associated with the committer email address in the commit. || unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. || bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. || unknown_key | The key that made the signature has not been registered with any user's account. || malformed_signature | There was an error parsing the signature. || invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. || valid | None of the above errors applied, so the signature is considered to be verified. | |
list_commits | select | owner, repo | sha, path, author, committer, since, until, per_page, page | Signature verification object The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:| Name | Type | Description | | ---- | ---- | ----------- | | verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. || reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. || signature | string | The signature that was extracted from the commit. || payload | string | The value that was signed. || verified_at | string | The date the signature was verified by GitHub. |These are the possible values for reason in the verification object:| Value | Description | | ----- | ----------- | | expired_key | The key that made the signature is expired. || not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. || gpgverify_error | There was an error communicating with the signature verification service. || gpgverify_unavailable | The signature verification service is currently unavailable. || unsigned | The object does not include a signature. || unknown_signature_type | A non-PGP signature was found in the commit. || no_user | No user was associated with the committer email address in the commit. || unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. || bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. || unknown_key | The key that made the signature has not been registered with any user's account. || malformed_signature | There was an error parsing the signature. || invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. || valid | None of the above errors applied, so the signature is considered to be verified. | |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
basehead | string | The base branch and head branch to compare. This parameter expects the format BASE...HEAD. Both must be branch names in repo. To compare with a branch that exists in a different repository in the same network as repo, the basehead parameter expects the format USERNAME:BASE...USERNAME:HEAD. |
owner | string | The account owner of the repository. The name is not case sensitive. |
ref | string | The commit reference. Can be a commit SHA, branch name (heads/BRANCH_NAME), or tag name (tags/TAG_NAME). For more information, see "Git References" in the Git documentation. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
author | string | GitHub username or email address to use to filter by commit author. |
committer | string | GitHub username or email address to use to filter by commit committer. |
page | integer | The page number of the results to fetch. For more information, see "Using pagination in the REST API." |
path | string | Only commits containing this file path will be returned. |
per_page | integer | The number of results per page (max 100). For more information, see "Using pagination in the REST API." |
sha | string | SHA or branch to start listing commits from. Default: the repository’s default branch (usually main). |
since | string (date-time) | Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned. |
until | string (date-time) | Only commits before this date will be returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned. |
SELECT examples
- get_commit
- compare_commits
- list_commits
Returns the contents of a single commit reference. You must have read access for the repository to use this endpoint.
> [!NOTE]
> If there are more than 300 files in the commit diff and the default JSON media type is requested, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing.
This endpoint supports the following custom media types. For more information, see "Media types." Pagination query parameters are not supported for these media types.
- application/vnd.github.diff: Returns the diff of the commit. Larger diffs may time out and return a 5xx status code.
- application/vnd.github.patch: Returns the patch of the commit. Diffs with binary data will have no patch property. Larger diffs may time out and return a 5xx status code.
- application/vnd.github.sha: Returns the commit's SHA-1 hash. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag.
Signature verification object
The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:
| Name | Type | Description |
| ---- | ---- | ----------- |
| verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. |
| reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. |
| signature | string | The signature that was extracted from the commit. |
| payload | string | The value that was signed. |
| verified_at | string | The date the signature was verified by GitHub. |
These are the possible values for reason in the verification object:
| Value | Description |
| ----- | ----------- |
| expired_key | The key that made the signature is expired. |
| not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
| gpgverify_error | There was an error communicating with the signature verification service. |
| gpgverify_unavailable | The signature verification service is currently unavailable. |
| unsigned | The object does not include a signature. |
| unknown_signature_type | A non-PGP signature was found in the commit. |
| no_user | No user was associated with the committer email address in the commit. |
| unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. |
| bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. |
| unknown_key | The key that made the signature has not been registered with any user's account. |
| malformed_signature | There was an error parsing the signature. |
| invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
| valid | None of the above errors applied, so the signature is considered to be verified. |
SELECT
node_id,
author,
comments_url,
commit,
committer,
files,
html_url,
parents,
sha,
stats,
url
FROM github.repos.commits
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND ref = '{{ ref }}' -- required
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
;
Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "Understanding connections between repositories."
This endpoint is equivalent to running the git log BASE..HEAD command, but it returns commits in a different order. The git log BASE..HEAD command returns commits in reverse chronological order, whereas the API returns commits in chronological order.
This endpoint supports the following custom media types. For more information, see "Media types."
- application/vnd.github.diff: Returns the diff of the commit.
- application/vnd.github.patch: Returns the patch of the commit. Diffs with binary data will have no patch property.
The API response includes details about the files that were changed between the two commits. This includes the status of the change (if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a renamed status have a previous_filename field showing the previous filename of the file, and files with a modified status have a patch field showing the changes made to the file.
When calling this endpoint without any paging parameter (per_page or page), the returned list is limited to 250 commits, and the last commit in the list is the most recent of the entire comparison.
Working with large comparisons
To process a response with a large number of commits, use a query parameter (per_page or page) to paginate the results. When using pagination:
- The list of changed files is only shown on the first page of results, and it includes up to 300 changed files for the entire comparison.
- The results are returned in chronological order, but the last commit in the returned list may not be the most recent one in the entire set if there are more pages of results.
For more information on working with pagination, see "Using pagination in the REST API."
Signature verification object
The response will include a verification object that describes the result of verifying the commit's signature. The verification object includes the following fields:
| Name | Type | Description |
| ---- | ---- | ----------- |
| verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. |
| reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. |
| signature | string | The signature that was extracted from the commit. |
| payload | string | The value that was signed. |
| verified_at | string | The date the signature was verified by GitHub. |
These are the possible values for reason in the verification object:
| Value | Description |
| ----- | ----------- |
| expired_key | The key that made the signature is expired. |
| not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
| gpgverify_error | There was an error communicating with the signature verification service. |
| gpgverify_unavailable | The signature verification service is currently unavailable. |
| unsigned | The object does not include a signature. |
| unknown_signature_type | A non-PGP signature was found in the commit. |
| no_user | No user was associated with the committer email address in the commit. |
| unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. |
| bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. |
| unknown_key | The key that made the signature has not been registered with any user's account. |
| malformed_signature | There was an error parsing the signature. |
| invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
| valid | None of the above errors applied, so the signature is considered to be verified. |
SELECT
ahead_by,
base_commit,
behind_by,
commits,
diff_url,
files,
html_url,
merge_base_commit,
patch_url,
permalink_url,
status,
total_commits,
url
FROM github.repos.commits
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND basehead = '{{ basehead }}' -- required
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
;
Signature verification object
The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:
| Name | Type | Description |
| ---- | ---- | ----------- |
| verified | boolean | Indicates whether GitHub considers the signature in this commit to be verified. |
| reason | string | The reason for verified value. Possible values and their meanings are enumerated in table below. |
| signature | string | The signature that was extracted from the commit. |
| payload | string | The value that was signed. |
| verified_at | string | The date the signature was verified by GitHub. |
These are the possible values for reason in the verification object:
| Value | Description |
| ----- | ----------- |
| expired_key | The key that made the signature is expired. |
| not_signing_key | The "signing" flag is not among the usage flags in the GPG key that made the signature. |
| gpgverify_error | There was an error communicating with the signature verification service. |
| gpgverify_unavailable | The signature verification service is currently unavailable. |
| unsigned | The object does not include a signature. |
| unknown_signature_type | A non-PGP signature was found in the commit. |
| no_user | No user was associated with the committer email address in the commit. |
| unverified_email | The committer email address in the commit was associated with a user, but the email address is not verified on their account. |
| bad_email | The committer email address in the commit is not included in the identities of the PGP key that made the signature. |
| unknown_key | The key that made the signature has not been registered with any user's account. |
| malformed_signature | There was an error parsing the signature. |
| invalid | The signature could not be cryptographically verified using the key whose key-id was found in the signature. |
| valid | None of the above errors applied, so the signature is considered to be verified. |
SELECT
node_id,
author,
comments_url,
commit,
committer,
files,
html_url,
parents,
sha,
stats,
url
FROM github.repos.commits
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND sha = '{{ sha }}'
AND path = '{{ path }}'
AND author = '{{ author }}'
AND committer = '{{ committer }}'
AND since = '{{ since }}'
AND until = '{{ until }}'
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;