Skip to main content
The Gitea API provides endpoints for retrieving commit information, including individual commits, commit lists, and commit diffs.

Get Single Commit

Retrieve a single commit by its SHA or git reference.
GET /repos/{owner}/{repo}/git/commits/{sha}

Path Parameters

owner
string
required
Owner of the repository
repo
string
required
Name of the repository
sha
string
required
A git reference or commit SHA

Query Parameters

stat
boolean
default:"true"
Include diff stats for the commit (disable for speedup)
verification
boolean
default:"true"
Include verification information for the commit (disable for speedup)
files
boolean
default:"true"
Include list of affected files (disable for speedup)

Response

sha
string
Commit SHA hash
url
string
API URL for the commit
html_url
string
Web URL to view the commit
commit
object
Commit information
author
object
Author information
name
string
Author name
email
string
Author email
date
string
Author date (ISO 8601)
committer
object
Committer information (same structure as author)
message
string
Commit message
tree
object
Tree information
sha
string
Tree SHA
url
string
API URL for the tree
verification
object
Commit signature verification
verified
boolean
Whether the signature is verified
reason
string
Verification status reason
parents
array
Array of parent commit metadata
files
array
Array of affected files
filename
string
Path of the affected file
status
string
File status: added, modified, deleted
stats
object
Commit statistics
total
integer
Total lines changed
additions
integer
Lines added
deletions
integer
Lines deleted
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/git/commits/abc123" \
  -H "Authorization: token YOUR_TOKEN"

List All Commits

Get a list of all commits from a repository.
GET /repos/{owner}/{repo}/commits

Path Parameters

owner
string
required
Owner of the repository
repo
string
required
Name of the repository

Query Parameters

sha
string
SHA or branch to start listing commits from (usually ‘master’ or ‘main’)
path
string
Filepath of a file/directory to filter commits
since
string
Only commits after this date (ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ)
until
string
Only commits before this date (ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ)
stat
boolean
default:"true"
Include diff stats for every commit
verification
boolean
default:"true"
Include verification for every commit
files
boolean
default:"true"
Include list of affected files for every commit
not
string
Commits that match the given specifier will not be listed
page
integer
default:"1"
Page number of results (1-based)
limit
integer
Page size of results (ignored if used with ‘path’)

Response

Returns an array of commit objects (same structure as Get Single Commit).
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/commits?sha=main&page=1&limit=10" \
  -H "Authorization: token YOUR_TOKEN"
The response includes pagination headers:
  • X-Total-Count: Total number of commits
  • X-Page: Current page number
  • X-PerPage: Number of items per page
  • X-PageCount: Total number of pages
  • X-HasMore: Whether more pages exist

Download Commit Diff or Patch

Get a commit’s diff or patch file.
GET /repos/{owner}/{repo}/git/commits/{sha}.{diffType}

Path Parameters

owner
string
required
Owner of the repository
repo
string
required
Name of the repository
sha
string
required
SHA of the commit to get
diffType
string
required
Output format: diff or patch

Response

Returns plain text diff or patch content.
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/git/commits/abc123.diff" \
  -H "Authorization: token YOUR_TOKEN"

Get Commit Pull Request

Retrieve the pull request that merged this commit.
GET /repos/{owner}/{repo}/commits/{sha}/pull

Path Parameters

owner
string
required
Owner of the repository
repo
string
required
Name of the repository
sha
string
required
SHA of the commit

Response

Returns a pull request object if the commit was part of a merged pull request.
id
integer
Pull request ID
number
integer
Pull request number
title
string
Pull request title
state
string
Pull request state: open, closed, merged
merged
boolean
Whether the pull request was merged
merged_at
string
Timestamp when merged (ISO 8601)
merge_commit_sha
string
SHA of the merge commit
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/commits/abc123/pull" \
  -H "Authorization: token YOUR_TOKEN"

Common Use Cases

List Recent Commits

Get the most recent commits from the default branch:
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/commits?limit=20" \
  -H "Authorization: token YOUR_TOKEN"

Get Commits by Author

While the API doesn’t have a direct author filter, you can filter commits after fetching them or use the since parameter combined with knowing when the author was active.

Track File History

Get all commits that affected a specific file:
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/commits?path=src/main.go" \
  -H "Authorization: token YOUR_TOKEN"

Verify Commit Signatures

Include verification information for all commits:
curl -X GET "https://gitea.example.com/api/v1/repos/username/repo-name/commits?verification=true" \
  -H "Authorization: token YOUR_TOKEN"

Build docs developers (and LLMs) love