GitLab API icon

GitLab API

Gitlab

Actions1062

Projects → getApiV4ProjectsIdRepositoryCompare

AI-generated

Summary

Compare two commits, branches, or tags in a GitLab project's repository to see the differences between them.

Inputs

  • id (required) — The ID or URL-encoded path of the project to compare.
  • from (required) — The commit SHA, branch name, or tag name to start the comparison from.
  • to (required) — The commit SHA, branch name, or tag name to end the comparison at.
  • from_project_id — Optional project ID to compare from if different from the main project.
  • straight — Boolean indicating whether to compare directly between from and to (true) or using the merge base (false). Defaults to false.
  • unidiff — Boolean to request the diff in Unified diff format.
  • skipAuthentication — Boolean to skip authentication for this request; defaults to false.
  • baseUrl — Base URL for the GitLab instance; defaults to https://gitlab.com.
  • method — HTTP method to use for the request, default is GET.

Output shape

a JSON object representing the comparison result, including commits, diffs, and other metadata between the specified references

The response follows GitLab's API structure for repository comparison. Optional query parameters influence the diff output format and comparison method. Authentication is required unless explicitly skipped.

Examples

Example 1: Compare the 'main' branch to the 'feature' branch in project ID '1' using merge base comparison.

Set 'id' to '1', 'from' to 'main', 'to' to 'feature', and omit optional parameters to use defaults.

Links

Discussion