Skip to content

Commit

A commit is the unit of a repository's version history. With the API you can list and read commits, compare two references, get the diff and patch, view code contribution statistics, and post comments on commits.

Objects

Object Description Related endpoints
Commit SHA, author, commit information, change statistics Get all repository commits
Comparison Commits and file differences between two references Commits comparison
Diff / Patch Diff and patch content of a single commit Get commit diff
Commit comment Comments on a commit; you can create, delete, update, and query them Create a commit comment
Contribution statistics Added and deleted code lines and commit counts by person / by date Get code contribution statistics

Identification

  • A repository is identified by owner + repo; a commit is identified by sha or ref (branch name, tag name, etc.).
  • A comparison uses the ellipsis form {base}...{head} in the path.
  • A comment is identified by id; to query comments for a commit, use sha or ref.

Common tasks

Notes

  • The commit itself uses the plural /commits/{sha}, while diff and patch use the singular /commit/{sha}/diff (/patch); the two path families coexist.
  • The code contribution statistics path is missing the repos/ segment: GET /api/v5/{owner}/{repo}/repository/commit_statistics, which differs from how the other endpoints are formed.
  • Comments have three entry points: per commit /commits/{sha}/comments (write), per ref /commits/{ref}/comments (read), and all comments in the repository /comments (read); reading, updating, and deleting a single comment all go through /comments/{id}.
  • The comparison endpoint path must be written as {base}...{head} (three dots), not a slash or two dots.

Endpoint list

This module contains 12 endpoints in total.

# Endpoint Method and path Description
1 Get all repository commits GET /api/v5/repos/{owner}/{repo}/commits This endpoint retrieves all commits in the specified repository. You can filter by commit SHA, file path, author, and time range, and browse the commit history with pagination…
2 A commit in a repository GET /api/v5/repos/{owner}/{repo}/commits/{sha} This endpoint returns details about a specific commit in the specified repository, including the commit information, author and committer, change statistics, and the list of changed files. Use the show_d…
3 Commits comparison GET /api/v5/repos/{owner}/{repo}/compare/{base}...{head} This endpoint returns the comparison result between two commits in the specified repository. You can use a commit SHA, branch name, or tag name as the start and end points of the comparison, and it returns…
4 Create a commit comment POST /api/v5/repos/{owner}/{repo}/commits/{sha}/comments This endpoint creates a comment on a specific commit in the specified repository. You must provide the namespace that owns the repository, the repository path, and the commit ID, and submit the…
5 Delete a commit comment DELETE /api/v5/repos/{owner}/{repo}/comments/{id} This endpoint deletes a comment on a commit in the specified repository. You must provide the namespace address that owns the repository, the repository path, and the comment ID to locate the target comment. On success, it return…
6 Get a specific commit comment in a repository GET /api/v5/repos/{owner}/{repo}/comments/{id} This endpoint returns the details of a specific commit comment in the specified repository: the comment content, creation time, update time, comment target object, and the user information of the poster…
7 Update a commit comment PATCH /api/v5/repos/{owner}/{repo}/comments/{id} This endpoint updates the content of a comment on a specific commit. You must specify the namespace address that owns the repository, the repository path, and the comment ID, and pass it in the request body…
8 Get a repository's commit comments GET /api/v5/repos/{owner}/{repo}/comments This endpoint returns the list of commit comments in the specified repository. You can paginate with the page number and per-page parameters and choose ascending or descending order…
9 Get code contribution GET /api/v5/{owner}/{repo}/repository/commit_statistics This endpoint returns code contribution statistics for a branch in the specified repository, including commit records and each user's added and deleted lines and commit counts, which can be…
10 Get a single commit comment GET /api/v5/repos/{owner}/{repo}/commits/{ref}/comments This endpoint returns the comment list for a specific commit in the specified repository, with pagination. It returns the content, creation and update times of each comment, as well as information about the poster…
11 Get the diff of a commit GET /api/v5/repos/{owner}/{repo}/commit/{sha}/diff This endpoint returns the diff of a specific commit in the specified repository. Pass the namespace address that owns the repository, the repository path, and the co…
12 Get the patch of a commit GET /api/v5/repos/{owner}/{repo}/commit/{sha}/patch This endpoint returns the patch of a specific commit in the specified repository. It returns the file changes introduced by the commit in unified diff format…

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc