Use this API to manage Git commits.
List all repository commits
GET /api/v4/projects/{id}/repository/commits
Lists all commits for a specified project repository.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
ref_Query | String | The name of a repository branch or tag, Example: v1. |
sinceQuery | String (date- | Only commits after or on this date will be returned Example: 2021- |
untilQuery | String (date- | Only commits before or on this date will be returned Example: 2021- |
pathQuery | String | The file path Example: README. |
followQuery | Boolean | Follow file renames when filtering by path |
authorQuery | String | Search commits by commit author Example: John Smith |
allQuery | Boolean | Every commit will be returned |
with_Query | Boolean | Stats about each commit will be added to the response |
first_Query | Boolean | Only include the first parent of merges |
orderQuery | String | List commits in order Allowed values: default,topoDefault: default |
trailersQuery | Boolean | Parse and include Git trailers for every commit Default: false |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
paginationQuery | String | Specify the pagination method Allowed values: legacy,keysetDefault: legacy |
page_Query | String | Record from which to start the keyset pagination |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
404 | Not found | — |
Create a commit
POST /api/v4/projects/{id}/repository/commits
This feature was introduced in GitLab 8.13
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
Request body (multipart/form-data)
| Property | Type | Description |
|---|---|---|
fileRequired | String (binary) | The commit content to be created (generated by Multipart middleware) |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
401 | Unauthorized | — |
403 | Forbidden | — |
404 | Not found | — |
Retrieve a commit
GET /api/v4/projects/{id}/repository/commits/{sha}
Retrieves a specified commit identified by the commit hash or name of a branch or tag.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
statsQuery | Boolean | Include commit stats Default: true |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Cherry-pick a commit
POST /api/v4/projects/{id}/repository/commits/{sha}/cherry_pick
Cherry-picks a commit to a specified branch.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branchRequired | String | The name of the branch Example: master |
dry_ | Boolean | Does not commit any changes Default: false |
message | String | A custom commit message to use for the picked commit Example: Initial commit |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
404 | Not found | — |
List all commit comments
GET /api/v4/projects/{id}/repository/commits/{sha}/comments
Lists all the comments of a commit in a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
shaPath, | String | A commit sha, |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Create a comment on a commit
POST /api/v4/projects/{id}/repository/commits/{sha}/comments
Creates a comment on a commit. To comment on a specific line in a file, specify the full commit SHA, path, line, and set line_type to new.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
lineRequired | Integer | The line number Example: 11 |
line_Required | String | The type of the line Allowed values: new,oldDefault: newMinimum length: 1 |
noteRequired | String | The text of the comment Example: Nice code! |
path | String | The file path Example: doc/ |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
404 | Not found | — |
Retrieve a commit diff
GET /api/v4/projects/{id}/repository/commits/{sha}/diff
Retrieves the diff of a commit in a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
unidiffQuery | Boolean | A diff in a Unified diff format Default: false |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
List all merge requests associated with a commit
GET /api/v4/projects/{id}/repository/commits/{sha}/merge_requests
Lists all merge requests associated with a specified commit.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
stateQuery | String | Filter merge- Example: merged |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
List all references a commit is pushed to
GET /api/v4/projects/{id}/repository/commits/{sha}/refs
Lists all references (from branches or tags) a commit is pushed to. The pagination parameters page and per_page can be used to restrict the list of references.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha |
typeQuery | String | Scope Allowed values: branch,tag,allDefault: all |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Revert a commit
POST /api/v4/projects/{id}/repository/commits/{sha}/revert
Reverts a commit in a specified branch.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | Commit SHA to revert |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branchRequired | String | Target branch name Example: master |
dry_ | Boolean | Does not commit any changes Default: false |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad request | — |
404 | Not found | — |
Retrieve a commit sequence
GET /api/v4/projects/{id}/repository/commits/{sha}/sequence
Retrieves the commit sequence for a specified commit.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit SHA |
first_Query | Boolean | Only include the first parent of merges Default: false |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Retrieve a commit signature
GET /api/v4/projects/{id}/repository/commits/{sha}/signature
Retrieves the signature from a commit, if it is signed. For unsigned commits, it results in a 404 response.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID or URL- |
shaPath, | String | A commit sha, |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesBasicRef
| Property | Type | Description |
|---|---|---|
name | String | Example:v1. |
type | String | Example:tag |
APIEntitiesCommit
| Property | Type | Description |
|---|---|---|
author_ | String | Example:john@example. |
author_ | String | Example:John Smith |
authored_ | String (date- | Example:2012- |
committed_ | String (date- | Example:2012- |
committer_ | String | Example:jack@example. |
committer_ | String | Example:Jack Smith |
created_ | String (date- | Example:2017- |
extended_ | Object | Example:{"Signed- |
id | String | Example:2695effb5807a22ff3d1 |
message | String | Example:Initial commit |
parent_ | Array of strings | Example:["2a4b78934375d7f53875 |
short_ | String | Example:2695effb |
title | String | Example:Initial commit |
trailers | Object | Example:{"Merged- |
web_ | String | Example:https: |
APIEntitiesCommitDetail
| Property | Type | Description |
|---|---|---|
author_ | String | Example:john@example. |
author_ | String | Example:John Smith |
authored_ | String (date- | Example:2012- |
committed_ | String (date- | Example:2012- |
committer_ | String | Example:jack@example. |
committer_ | String | Example:Jack Smith |
created_ | String (date- | Example:2017- |
extended_ | Object | Example:{"Signed- |
id | String | Example:2695effb5807a22ff3d1 |
last_ | Object | — |
message | String | Example:Initial commit |
parent_ | Array of strings | Example:["2a4b78934375d7f53875 |
project_ | Integer (int64) | Example:1 |
short_ | String | Example:2695effb |
stats | APIEntities | — |
status | String | Example:success |
title | String | Example:Initial commit |
trailers | Object | Example:{"Merged- |
web_ | String | Example:https: |
APIEntitiesCommitNote
| Property | Type | Description |
|---|---|---|
author | APIEntities | — |
created_ | String (date- | Example:2016- |
line | Integer | Example:11 |
line_ | String | Example:new |
note | String | Example:this doc is really nice |
path | String | Example:README. |
APIEntitiesCommitSequence
| Property | Type | Description |
|---|---|---|
count | Integer | Example:1 |
APIEntitiesCommitSignature
| Property | Type | Description |
|---|---|---|
commit_ | String | Example:gitaly |
signature | Object | — |
signature_ | String | Example:PGP |
APIEntitiesCommitStats
| Property | Type | Description |
|---|---|---|
additions | Integer | Example:1 |
deletions | Integer | Example:0 |
total | Integer | Example:1 |
APIEntitiesCustomAttribute
| Property | Type | Description |
|---|---|---|
key | String | Example:foo |
value | String | Example:bar |
APIEntitiesDiff
| Property | Type | Description |
|---|---|---|
a_ | String | Example:100755 |
b_ | String | Example:100644 |
collapsed | Boolean | — |
deleted_ | Boolean | — |
diff | String | Example:@@ - |
generated_ | Boolean | — |
new_ | Boolean | — |
new_ | String | Example:doc/ |
old_ | String | Example:doc/ |
renamed_ | Boolean | — |
too_ | Boolean | — |
APIEntitiesIssuableReferences
| Property | Type | Description |
|---|---|---|
full | String | Example:test&6 |
relative | String | Example:&6 |
short | String | Example:&6 |
APIEntitiesIssuableTimeStats
| Property | Type | Description |
|---|---|---|
human_ | String | Example:3h 30m |
human_ | String | Example:1h |
time_ | Integer | Example:12600 |
total_ | Integer | Example:3600 |
APIEntitiesMergeRequestBasic
| Property | Type | Description |
|---|---|---|
allow_ | Boolean | — |
allow_ | Boolean | — |
assignee | APIEntities | — |
assignees | APIEntities | — |
author | APIEntities | — |
blocking_ | Boolean | — |
closed_ | String (date- | Example:2022- |
closed_ | APIEntities | — |
created_ | String (date- | Example:2022- |
description | String | Example:Repellendus impedit et vel velit dignissimos. |
description_ | String | — |
detailed_ | String | Example:mergeable |
discussion_ | Boolean | — |
downvotes | Integer | — |
draft | Boolean | — |
force_ | Boolean | — |
has_ | Boolean | — |
id | Integer (int64) | Example:84 |
iid | Integer | Example:14 |
imported | Boolean | — |
imported_ | String | Example:bitbucket |
labels | Array of strings | — |
merge_ | String (date- | Example:2022- |
merge_ | String | Example:1234abcd |
merge_ | String | Example:unchecked |
merge_ | APIEntities | — |
merge_ | Boolean | — |
merged_ | String (date- | Example:2022- |
merged_ | APIEntities | — |
milestone | APIEntities | — |
prepared_ | String (date- | Example:2022- |
project_ | Integer (int64) | Example:4 |
reference | String | Example:!1 |
references | APIEntities | — |
reviewers | APIEntities | — |
sha | String | Example:1234abcd |
should_ | Boolean | — |
source_ | String | — |
source_ | Integer (int64) | — |
squash | Boolean | — |
squash_ | String | Example:1234abcd |
squash_ | Boolean | — |
state | String | Example:closed |
target_ | String | — |
target_ | Integer (int64) | — |
task_ | APIEntities | — |
time_ | APIEntities | — |
title | String | Example:Impedit et ut et dolores vero provident ullam est |
title_ | String | — |
updated_ | String (date- | Example:2022- |
upvotes | Integer | — |
user_ | Integer | — |
web_ | String | Example:https: |
work_ | Boolean | — |
APIEntitiesMilestone
| Property | Type | Description |
|---|---|---|
created_ | String | — |
description | String | — |
due_ | String | — |
expired | Boolean | — |
group_ | String | — |
id | Integer (int64) | — |
iid | Integer (int64) | — |
project_ | Integer (int64) | — |
start_ | String | — |
state | String | — |
title | String | — |
updated_ | String | — |
web_ | String | — |
APIEntitiesTaskCompletionStatus
| Property | Type | Description |
|---|---|---|
completed_ | Integer | Example:3 |
count | Integer | Example:5 |
APIEntitiesUserBasic
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:/ |
avatar_ | String | Example:https: |
custom_ | Array of APIEntities | — |
id | Integer (int64) | Example:1 |
locked | Boolean | — |
name | String | Example:Administrator |
public_ | String | Example:john@example. |
state | String | Example:active |
username | String | Example:admin |
web_ | String | Example:https: |