Compare branches, tags, or commits
GET
/api/v4/projects/{id}/repository/compare
Compares branches, tags, or commits. Retrieves the differences between two branches, tags, or commits in a specified project.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”Query Parameters
Section titled “ Query Parameters ” from
required
string
The commit, branch name, or tag name to start comparison
Example
main to
required
string
The commit, branch name, or tag name to stop comparison
Example
feature from_project_id
integer
The project to compare from
Example
1 straight
boolean
Comparison method, true for direct comparison between from and to (from..to), false to compare using merge base (from…to)
unidiff
boolean
A diff in a Unified diff format
Responses
Section titled “ Responses ”OK
Media type application/json
object
commit
object
id
string
short_id
string
created_at
string format: date-time
parent_ids
Array<string>
title
string
message
string
author_name
string
author_email
string
authored_date
string format: date-time
committer_name
string
committer_email
string
committed_date
string format: date-time
trailers
object
extended_trailers
object
web_url
string
commits
Array<object>
object
id
string
short_id
string
created_at
string format: date-time
parent_ids
Array<string>
title
string
message
string
author_name
string
author_email
string
authored_date
string format: date-time
committer_name
string
committer_email
string
committed_date
string format: date-time
trailers
object
extended_trailers
object
web_url
string
diffs
Array<object>
object
diff
string
collapsed
boolean
too_large
boolean
new_path
string
old_path
string
a_mode
string
b_mode
string
new_file
boolean
renamed_file
boolean
deleted_file
boolean
generated_file
boolean
compare_timeout
boolean
compare_same_ref
boolean
web_url
string
Example
{ "commit": { "id": "2695effb5807a22ff3d138d593fd856244e155e7", "short_id": "2695effb", "created_at": "2017-07-26T11:08:53.000+02:00", "parent_ids": [ "2a4b78934375d7f53875269ffd4f45fd83a84ebe" ], "title": "Initial commit", "message": "Initial commit", "author_name": "John Smith", "author_email": "john@example.com", "authored_date": "2012-05-28T04:42:42-07:00", "committer_name": "Jack Smith", "committer_email": "jack@example.com", "committed_date": "2012-05-28T04:42:42-07:00", "trailers": { "Merged-By": "Jane Doe janedoe@gitlab.com" }, "extended_trailers": { "Signed-off-by": [ "John Doe <johndoe@gitlab.com>", "Jane Doe <janedoe@gitlab.com>" ] }, "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746" }, "commits": [ { "id": "2695effb5807a22ff3d138d593fd856244e155e7", "short_id": "2695effb", "created_at": "2017-07-26T11:08:53.000+02:00", "parent_ids": [ "2a4b78934375d7f53875269ffd4f45fd83a84ebe" ], "title": "Initial commit", "message": "Initial commit", "author_name": "John Smith", "author_email": "john@example.com", "authored_date": "2012-05-28T04:42:42-07:00", "committer_name": "Jack Smith", "committer_email": "jack@example.com", "committed_date": "2012-05-28T04:42:42-07:00", "trailers": { "Merged-By": "Jane Doe janedoe@gitlab.com" }, "extended_trailers": { "Signed-off-by": [ "John Doe <johndoe@gitlab.com>", "Jane Doe <janedoe@gitlab.com>" ] }, "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746" } ], "diffs": [ { "diff": "@@ -71,6 +71,8 @@\\n...", "new_path": "doc/update/5.4-to-6.0.md", "old_path": "doc/update/5.4-to-6.0.md", "a_mode": "100755", "b_mode": "100644" } ], "web_url": "https://gitlab.example.com/gitlab/gitlab-foss/-/compare/main...feature"}Bad Request
Not Found