---
title: "Get commit comparison information"
method: GET
path: "/repos/{owner}/{repo}/compare/{basehead}"
tags: ["repository"]
---

# Get commit comparison information

`GET /repos/{owner}/{repo}/compare/{basehead}`

## Request

- Base URL: `https://demo.gitea.com/api/v1`
- URL: `https://demo.gitea.com/api/v1/repos/{owner}/{repo}/compare/{basehead}`
- Auth: one of:
  - HTTP basic
  - API key in query parameter `token`
  - API key in query parameter `access_token`
  - API key in header `Authorization`
  - API key in query parameter `sudo`
  - API key in header `Sudo`
  - API key in header `X-GITEA-OTP`

By default returns JSON commit comparison information. The raw diff or patch can be
requested with the `output` query parameter set to `diff` or `patch` respectively.

## Path parameters

- `owner` string, required
- `repo` string, required
- `basehead` string, required

## Query parameters

- `output` 'diff' | 'patch'
- `verification` boolean
- `files` boolean

## Response `200`

- Compare
  - `commits` Commit[]
    - `author` User: User represents a user
      - `active` boolean: Is user active
      - `avatar_url` string: URL to the user's avatar
      - `created` string, date-time
      - `description` string: the user's description
      - `email` string, email
      - `followers_count` integer: user counts
      - `following_count` integer
      - `full_name` string: the user's full name
      - `html_url` string: URL to the user's gitea page
      - `id` integer: the user's id
      - `is_admin` boolean: Is the user an administrator
      - `language` string: User locale
      - `last_login` string, date-time
      - `location` string: the user's location
      - `login` string: login of the user, same as `username`
      - `login_name` string: identifier of the user, provided by the external authenticator (if configured)
      - `prohibit_login` boolean: Is user login prohibited
      - `restricted` boolean: Is user restricted
      - `source_id` integer: The ID of the user's Authentication Source
      - `starred_repos_count` integer
      - `type` 'User' | 'Organization' | 'Bot': the user type
      - `visibility` 'public' | 'limited' | 'private': User visibility level option: public, limited, private
      - `website` string: the user's website
    - `commit` RepoCommit
      - `author` CommitUser
        - `date` string: Date is the commit date in string format
        - `email` string, email: Email is the person's email address
        - `name` string: Name is the person's name
      - `committer` CommitUser
        - `date` string: Date is the commit date in string format
        - `email` string, email: Email is the person's email address
        - `name` string: Name is the person's name
      - `message` string: Message is the commit message
      - `tree` CommitMeta
        - `created` string, date-time: Created is the time when the commit was created
        - `sha` string: SHA is the commit SHA hash
        - `url` string: URL is the API URL for the commit
      - `url` string: URL is the API URL for the commit
      - `verification` PayloadCommitVerification: PayloadCommitVerification represents the GPG verification of a commit
        - `payload` string: The signed payload content
        - `reason` string: The reason for the verification status
        - `signature` string: The GPG signature of the commit
        - `signer` PayloadUser: PayloadUser represents the author or committer of a commit
          - `email` string, email
          - `name` string: Full name of the commit author
          - `username` string: username of the user
        - `verified` boolean: Whether the commit signature is verified
    - `committer` User: User represents a user
      - `active` boolean: Is user active
      - `avatar_url` string: URL to the user's avatar
      - `created` string, date-time
      - `description` string: the user's description
      - `email` string, email
      - `followers_count` integer: user counts
      - `following_count` integer
      - `full_name` string: the user's full name
      - `html_url` string: URL to the user's gitea page
      - `id` integer: the user's id
      - `is_admin` boolean: Is the user an administrator
      - `language` string: User locale
      - `last_login` string, date-time
      - `location` string: the user's location
      - `login` string: login of the user, same as `username`
      - `login_name` string: identifier of the user, provided by the external authenticator (if configured)
      - `prohibit_login` boolean: Is user login prohibited
      - `restricted` boolean: Is user restricted
      - `source_id` integer: The ID of the user's Authentication Source
      - `starred_repos_count` integer
      - `type` 'User' | 'Organization' | 'Bot': the user type
      - `visibility` 'public' | 'limited' | 'private': User visibility level option: public, limited, private
      - `website` string: the user's website
    - `created` string, date-time: Created is the time when the commit was created
    - `files` CommitAffectedFiles[]: Files contains information about files affected by the commit
      - `filename` string: Filename is the path of the affected file
      - `status` string: Status indicates how the file was affected (added, modified, deleted)
    - `html_url` string: HTMLURL is the web URL for viewing the commit
    - `parents` CommitMeta[]: Parents contains the parent commit information
      - `created` string, date-time: Created is the time when the commit was created
      - `sha` string: SHA is the commit SHA hash
      - `url` string: URL is the API URL for the commit
    - `sha` string: SHA is the commit SHA hash
    - `stats` CommitStats: CommitStats is statistics for a RepoCommit
      - `additions` integer: Additions is the number of lines added
      - `deletions` integer: Deletions is the number of lines deleted
      - `total` integer: Total is the total number of lines changed
    - `url` string: URL is the API URL for the commit
  - `total_commits` integer

## Other responses

- `default`: APIError is error format response

## Changes

- **2026-10-28** `7ef50c4c527f`: 2 info
  - removed the non-success response with the status `400`
  - removed the non-success response with the status `404`
- **2026-10-07** `b0b1b4890863`: 2 info
  - added the new optional `query` request parameter `files`
  - added the new optional `query` request parameter `verification`
- **2026-07-13** `4df6be504c96`: 2 info
  - added the new optional `query` request parameter `output`
  - added the non-success response with the status `400`

[Operation history](https://skmtc.dev/gitea/apis/gitea-api/changes/repos/:owner/:repo/compare/:basehead/get.md)

---

[API](https://skmtc.dev/gitea/apis/gitea-api.md) - [All operations](https://skmtc.dev/gitea/apis/gitea-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitea/apis/gitea-api/revisions/e0f0c1c43b8d?raw)
