Skip to main content
The CommitService provides RPCs for working with Git commits. This includes listing commits, searching by various criteria, retrieving commit metadata, analyzing commit statistics, and working with signatures.

ListCommits

Lists all commits reachable via a set of references by doing a graph walk. This deprecates FindAllCommits and FindCommits (except Follow is not yet supported).

Request

repository
Repository
required
The repository to search for commits
revisions
string[]
required
Set of revisions to walk. Accepts all notation as documented in gitrevisions(7) as well as the pseudo-revisions --not and --all. Must not be empty.
pagination_params
PaginationParameter
Pagination configuration. The page token is the last commit OID that was sent (full object ID).
order
Order
Order for traversing commits: NONE (reverse chronological), TOPO, or DATE
reverse
bool
List all commits in reverse order
max_parents
uint32
Skip commits with more than this many parents. If set to 1, all merge commits will be omitted. 0 means no filtering.
disable_walk
bool
Disable graph walking. Only commits immediately referenced by revisions will be returned.
first_parent
bool
Only follow the first-parent chain of commits
after
google.protobuf.Timestamp
Only list commits more recent than this date
before
google.protobuf.Timestamp
Only list commits older than this date
author
bytes
Only list commits whose author matches this regular expression

Response (Stream)

commits
GitCommit[]
List of commits found

Example

{
  "repository": {
    "storage_name": "default",
    "relative_path": "@hashed/ab/cd/abcd1234.git"
  },
  "revisions": ["main"],
  "order": "TOPO",
  "max_parents": 1,
  "pagination_params": {
    "limit": 100
  }
}

ListAllCommits

Lists all commits present in the repository, including those not reachable by any reference.

Request

repository
Repository
required
The repository to search for commits
pagination_params
PaginationParameter
Pagination configuration. The page token is the last commit OID (full object ID).

Response (Stream)

commits
GitCommit[]
List of commits found

FindCommit

Finds a single commit by revision.

Request

repository
Repository
required
The repository to search in
revision
bytes
required
The revision to find (commit ID, branch, tag, etc.)
trailers
bool
Include commit trailers in the response

Response

commit
GitCommit
The commit found, or null if not found

Example

{
  "repository": {
    "storage_name": "default",
    "relative_path": "@hashed/ab/cd/abcd1234.git"
  },
  "revision": "main",
  "trailers": true
}

CommitIsAncestor

Checks if a commit is an ancestor of another commit.

Request

repository
Repository
required
The repository to check in
ancestor_id
string
required
The potential ancestor commit ID
child_id
string
required
The potential descendant commit ID

Response

value
bool
True if ancestor_id is an ancestor of child_id

Example

{
  "repository": {
    "storage_name": "default",
    "relative_path": "@hashed/ab/cd/abcd1234.git"
  },
  "ancestor_id": "abc123...",
  "child_id": "def456..."
}

CountCommits

Counts commits matching specific criteria.

Request

repository
Repository
required
The repository to count commits in
revision
bytes
Starting revision for counting
after
google.protobuf.Timestamp
Only count commits after this date
before
google.protobuf.Timestamp
Only count commits before this date
path
bytes
Only count commits that touch this path
max_count
int32
Maximum number of commits to count
all
bool
Count all commits (mutually exclusive with revision)
first_parent
bool
Only follow first-parent chain

Response

count
int32
Number of commits found

CountDivergingCommits

Counts how many commits differ between two references.

Request

repository
Repository
required
The repository to analyze
from
bytes
required
Starting reference
to
bytes
required
Ending reference
max_count
int32
Maximum count to return

Response

left_count
int32
Number of commits unique to the ‘from’ reference
right_count
int32
Number of commits unique to the ‘to’ reference

CommitStats

Retrieves statistics about a commit (additions and deletions).

Request

repository
Repository
required
The repository containing the commit
revision
bytes
required
The commit revision

Response

oid
string
The commit OID. Empty if not found.
additions
int32
Number of lines added
deletions
int32
Number of lines deleted

TreeEntry

Retrieves a tree entry (file or directory) at a specific path and revision.

Request

repository
Repository
required
The repository to retrieve from
revision
bytes
required
Commit ID or refname
path
bytes
required
Entry path relative to repository root
limit
int64
Maximum bytes to fetch. 0 means no limit. Remaining bytes are not sent if object is bigger.
max_size
int64
Maximum allowed object size. Returns FailedPrecondition error if bigger. 0 means no limit.

Response (Stream)

type
ObjectType
COMMIT, BLOB, TREE, or TAG
oid
string
SHA1 object ID
size
int64
Size of the object in bytes
mode
int32
File mode (e.g., 0644)
data
bytes
Raw object contents (may span multiple messages)

GetTreeEntries

Retrieves tree entries from a specific path.

Request

repository
Repository
required
The repository to retrieve from
revision
bytes
required
The revision to read from
path
bytes
Path to list entries from (empty for root)
recursive
bool
List entries recursively
sort
SortBy
Sort order: DEFAULT or TREES_FIRST
pagination_params
PaginationParameter
Pagination configuration

Response (Stream)

entries
TreeEntry[]
Array of tree entries
entries[].oid
string
Object ID this entry points to
entries[].path
bytes
Path relative to repository root
entries[].type
EntryType
BLOB, TREE, or COMMIT (submodule)
entries[].mode
int32
File mode (e.g., 0644)
pagination_cursor
PaginationCursor
Cursor for next page

ListFiles

Lists all files in a repository at a specific revision.

Request

repository
Repository
required
The repository to list files from
revision
bytes
required
The revision to list files at

Response (Stream)

paths
bytes[]
Array of file paths

FindAllCommits

Finds all commits reachable from a specific revision.

Request

repository
Repository
required
The repository to search in
revision
bytes
Starting revision. If nil, returns all commits reachable by any branch.
max_count
int32
Maximum number of commits to return
skip
int32
Number of commits to skip
order
Order
Sort order: NONE, TOPO, or DATE

Response (Stream)

commits
GitCommit[]
Array of commits

FindCommits

Finds commits with various filtering options.

Request

repository
Repository
required
The repository to search in
revision
bytes
Starting revision
limit
int32
Maximum number of commits to return
offset
int32
Number of commits to skip
paths
bytes[]
Only include commits that touch these paths
follow
bool
Follow file renames
skip_merges
bool
Skip merge commits
disable_walk
bool
Disable graph walking
after
google.protobuf.Timestamp
Only commits after this date
before
google.protobuf.Timestamp
Only commits before this date
all
bool
Search all references (mutually exclusive with revision)
first_parent
bool
Only follow first-parent chain
author
bytes
Filter by author pattern
order
Order
Sort order: NONE or TOPO
trailers
bool
Include commit trailers

Response (Stream)

commits
GitCommit[]
Array of commits

CommitLanguages

Analyzes the programming languages used in a commit.

Request

repository
Repository
required
The repository to analyze
revision
bytes
required
The commit revision to analyze

Response

languages
Language[]
Array of programming languages detected
languages[].name
string
Name of the programming language
languages[].share
float
Percentage share of this language (0.0 to 1.0)
languages[].color
string
Display color for this language
languages[].file_count
uint32
Number of files in this language
languages[].bytes
uint64
Total bytes of code in this language

RawBlame

Retrieves git blame information for a file.

Request

repository
Repository
required
The repository to blame from
revision
bytes
required
The revision to blame at
path
bytes
required
The file path to blame
range
bytes
Comma-separated range of line numbers (e.g., “1,1000”). Optional - if not provided, the whole file will be blamed.

Response (Stream)

data
bytes
Raw blame data

LastCommitForPath

Finds the last commit that modified a specific path.

Request

repository
Repository
required
The repository to search in
revision
bytes
required
The revision to search from
path
bytes
required
The path to find the last commit for
literal_pathspec
bool
Use literal pathspec (deprecated)

Response

commit
GitCommit
The last commit that modified the path, or null if not found

ListLastCommitsForTree

Lists the last commits for each entry in a tree.

Request

repository
Repository
required
The repository to search in
revision
string
required
The revision to search from
path
bytes
The tree path (empty for root)
limit
int32
Maximum number of results
offset
int32
Number of results to skip

Response (Stream)

commits
CommitForTree[]
Array of commits for tree entries
commits[].commit
GitCommit
The commit
commits[].path_bytes
bytes
The path this commit modified

CommitsByMessage

Finds commits by searching commit messages.

Request

repository
Repository
required
The repository to search in
revision
bytes
Starting revision
query
string
required
Search query for commit messages
offset
int32
Number of results to skip
limit
int32
Maximum number of results
path
bytes
Only search commits that touch this path

Response (Stream)

commits
GitCommit[]
Array of commits matching the query

ListCommitsByOid

Lists commits by their object IDs.

Request

repository
Repository
required
The repository to retrieve from
oid
string[]
required
Array of commit object IDs

Response (Stream)

commits
GitCommit[]
Array of commits found

ListCommitsByRefName

Lists commits by reference names.

Request

repository
Repository
required
The repository to retrieve from
ref_names
bytes[]
required
Array of reference names

Response (Stream)

commit_refs
CommitForRef[]
Array of commits with their reference names
commit_refs[].commit
GitCommit
The commit
commit_refs[].ref_name
bytes
The reference name

FilterShasWithSignatures

Filters a list of commit SHAs to only those with signatures.

Request (Stream)

repository
Repository
required
The repository to check
shas
bytes[]
Array of commit SHAs to check

Response (Stream)

shas
bytes[]
Array of SHAs that have signatures

GetCommitSignatures

Retrieves cryptographic signatures for commits.

Request

repository
Repository
required
The repository to retrieve from
commit_ids
string[]
required
Array of commit IDs

Response (Stream)

commit_id
string
The commit ID. Only present for a new commit signature.
signature
bytes
The cryptographic signature
signed_text
bytes
The text that was signed

GetCommitMessages

Retrieves commit messages for multiple commits.

Request

repository
Repository
required
The repository to retrieve from
commit_ids
string[]
required
Array of commit IDs

Response (Stream)

commit_id
string
The commit ID. Only present for a new commit message.
message
bytes
The commit message

CheckObjectsExist

Checks for the existence of revisions in a repository.

Request (Stream)

repository
Repository
required
The repository to check in
revisions
bytes[]
Array of revisions to check. Accepts all revisions as documented in gitrevisions(7).

Response (Stream)

revisions
RevisionExistence[]
Array of revision existence results
revisions[].name
bytes
The revision name
revisions[].exists
bool
Whether the revision exists

Build docs developers (and LLMs) love