In commit responses, created_at and committed_date are identical.
However, committed_date and authored_date are generated from different sources,
and may not be identical.
An array of action hashes to commit as a batch. See the next table for what attributes it can take.
author_email
string
no
Specify the commit author’s email address
author_name
string
no
Specify the commit author’s name
stats
boolean
no
Include commit stats. Default is true
force
boolean
no
When true overwrites the target branch with a new commit based on the start_branch or start_sha
actions[] Attribute
Type
Required
Description
action
string
yes
The action to perform, create, delete, move, update, chmod
file_path
string
yes
Full path to the file. Ex. lib/class.rb
previous_path
string
no
Original full path to the file being moved. Ex. lib/class1.rb. Only considered for move action.
content
string
no
File content, required for all except delete, chmod, and move. Move actions that do not specify content preserve the existing file content, and any other value of content overwrites the file content.
encoding
string
no
text or base64. text is default.
last_commit_id
string
no
Last known file commit ID. Only considered in update, move, and delete actions.
execute_filemode
boolean
no
When true/false enables/disables the execute flag on the file. Only considered for chmod action.
{"id":"6104942438c14ec7bd21c6cd5bd995272b3faff6","short_id":"6104942438c","title":"Sanitize for network graph","author_name":"randx","author_email":"user@example.com","committer_name":"Dmitriy","committer_email":"user@example.com","created_at":"2021-09-20T09:06:12.300+03:00","message":"Sanitize for network graph","committed_date":"2021-09-20T09:06:12.300+03:00","authored_date":"2021-09-20T09:06:12.420+03:00","parent_ids":["ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"],"last_pipeline":{"id":8,"ref":"master","sha":"2dc6aa325a317eda67812f05600bdf0fcdc70ab0","status":"created"},"stats":{"additions":15,"deletions":10,"total":25},"status":"running","web_url":"https://gitlab.example.com/thedude/gitlab-foss/-/commit/6104942438c14ec7bd21c6cd5bd995272b3faff6"}
Get references a commit is pushed to
Get 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.
curl --request POST --header"PRIVATE-TOKEN: <your_access_token>"\--form"branch=master""https://gitlab.example.com/api/v4/projects/5/repository/commits/master/cherry_pick"
Example response:
{"id":"8b090c1b79a14f2bd9e8a738f717824ff53aebad","short_id":"8b090c1b","author_name":"Example User","author_email":"user@example.com","authored_date":"2016-12-12T20:10:39.000+01:00","created_at":"2016-12-12T20:10:39.000+01:00","committer_name":"Administrator","committer_email":"admin@example.com","committed_date":"2016-12-12T20:10:39.000+01:00","title":"Feature added","message":"Feature added\n\nSigned-off-by: Example User <user@example.com>\n","parent_ids":["a738f717824ff53aebad8b090c1b79a14f2bd9e8"],"web_url":"https://gitlab.example.com/thedude/gitlab-foss/-/commit/8b090c1b79a14f2bd9e8a738f717824ff53aebad"}
In the event of a failed cherry-pick, the response provides context about
why:
{"message":"Sorry, we cannot cherry-pick this commit automatically. This commit may already have been cherry-picked, or a more recent commit may have updated some of its content.","error_code":"empty"}
In this case, the cherry-pick failed because the changeset was empty and likely
indicates that the commit already exists in the target branch. The other
possible error code is conflict, which indicates that there was a merge
conflict.
When dry_run is enabled, the server attempts to apply the cherry-pick but
not actually commit any resulting changes. If the cherry-pick applies cleanly,
the API responds with 200 OK:
{"dry_run":"success"}
In the event of a failure, an error displays that is identical to a failure without
dry run.
[{"note":"this code is really nice","author":{"id":11,"username":"admin","email":"admin@local.host","name":"Administrator","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]
Post comment to commit
Adds a comment to a commit.
To post a comment in a particular line of a particular file, you must specify
the full commit SHA, the path, the line, and line_type should be new.
The comment is added at the end of the last commit if at least one of the
cases below is valid:
the sha is instead a branch or a tag and the line or path are invalid
the line number is invalid (does not exist)
the path is invalid (does not exist)
In any of the above cases, the response of line, line_type and path is
set to null.
POST /projects/:id/repository/commits/:sha/comments
[{"id":"4604744a1c64de00ff62e1e8a6766919923d2b41","individual_note":true,"notes":[{"id":334686748,"type":null,"body":"I'm the Dude, so that's what you call me.","attachment":null,"author":{"id":28,"name":"Jeff Lebowski","username":"thedude","web_url":"https://gitlab.example.com/thedude","state":"active","avatar_url":"https://gitlab.example.com/uploads/user/avatar/28/The-Big-Lebowski-400-400.png"},"created_at":"2020-04-30T18:48:11.432Z","updated_at":"2020-04-30T18:48:11.432Z","system":false,"noteable_id":null,"noteable_type":"Commit","resolvable":false,"confidential":null,"noteable_iid":null,"commands_changes":{}}]}]
Commit status
This is the commit status API for use with GitLab.
List the statuses of a commit
List the statuses of a commit in a project.
The pagination parameters page and per_page can be used to restrict the list of references.
GET /projects/:id/repository/commits/:sha/statuses
The state of the status. Can be one of the following: pending, running, success, failed, canceled
ref
string
no
The ref (branch or tag) to which the status refers
name or context
string
no
The label to differentiate this status from the status of other systems. Default value is default
target_url
string
no
The target URL to associate with this status
description
string
no
The short description of the status
coverage
float
no
The total code coverage
pipeline_id
integer
no
The ID of the pipeline to set status. Use in case of several pipeline on same SHA.
curl --request POST --header"PRIVATE-TOKEN: <your_access_token>""https://gitlab.example.com/api/v4/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"
[{"id":45,"iid":1,"project_id":35,"title":"Add new file","description":"","state":"opened","created_at":"2018-03-26T17:26:30.916Z","updated_at":"2018-03-26T17:26:30.916Z","target_branch":"master","source_branch":"test-branch","upvotes":0,"downvotes":0,"author":{"web_url":"https://gitlab.example.com/thedude","name":"Jeff Lebowski","avatar_url":"https://gitlab.example.com/uploads/user/avatar/28/The-Big-Lebowski-400-400.png","username":"thedude","state":"active","id":28},"assignee":null,"source_project_id":35,"target_project_id":35,"labels":[],"draft":false,"work_in_progress":false,"milestone":null,"merge_when_pipeline_succeeds":false,"merge_status":"can_be_merged","sha":"af5b13261899fb2c0db30abdd0af8b07cb44fdc5","merge_commit_sha":null,"squash_commit_sha":null,"user_notes_count":0,"discussion_locked":null,"should_remove_source_branch":null,"force_remove_source_branch":false,"web_url":"http://https://gitlab.example.com/root/test-project/merge_requests/1","time_stats":{"time_estimate":0,"total_time_spent":0,"human_time_estimate":null,"human_total_time_spent":null}}]