Branches & Commits

June 17, 2026 ยท View on GitHub

Branch management, commit listing/inspection, file blame, and CI commit-status manipulation.

Tools in this group


create_branch

โœ๏ธ Writes

Create a new branch

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
branchstringโœ“Name for the new branch
refstringSource branch/commit for new branch

get_branch

๐Ÿ“– Read-only

Get branch details (commit, protection status)

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
branch_namestringโœ“Name of the branch

list_branches

๐Ÿ“– Read-only

List branches in project with search filter

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
searchstringSearch term to filter branches by name
pagenumberPage number for pagination (default: 1)
per_pagenumberNumber of items per page (max: 100, default: 20)

delete_branch

โœ๏ธ Writes

Delete branch from project

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
branch_namestringโœ“Name of the branch to delete

list_protected_branches

๐Ÿ“– Read-only

List protected branches in a project, supports search filter

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
searchstringSearch term to filter protected branches by name
pagenumberPage number for pagination (default: 1)
per_pagenumberNumber of items per page (max: 100, default: 20)

get_protected_branch

๐Ÿ“– Read-only

Get details of a single protected branch (access levels, force push settings)

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
branch_namestringโœ“Name of the protected branch

protect_branch

โœ๏ธ Writes

Protect a repository branch (set push/merge/unprotect access levels)

Parameters

ParameterTypeRequiredDescription
project_idstringProject ID or complete URL-encoded path to project
branch_namestringโœ“Branch name or wildcard pattern to protect
namestringDeprecated alias for branch_name; prefer branch_name for consistency
push_access_levelintegerAccess level for pushing (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
merge_access_levelintegerAccess level for merging (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
unprotect_access_levelintegerAccess level for unprotecting (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted.
allow_force_pushbooleanAllow force push to the protected branch. Default: false
code_owner_approval_requiredbooleanRequire code owner approval before merging (PREMIUM). Default: false

unprotect_branch

โœ๏ธ Writes

Remove protection from a previously protected branch

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
branch_namestringโœ“Name of the protected branch to unprotect

update_default_branch

โœ๏ธ Writes

Change the default branch of a project

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
default_branchstringโœ“The new default branch name for the project

list_commits

๐Ÿ“– Read-only

List repository commits with filtering options

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
ref_namestringThe name of a repository branch, tag or revision range, or if not given the default branch
sincestringOnly commits after or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ
untilstringOnly commits before or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ
pathstringThe file path
authorstringSearch commits by commit author
allbooleanRetrieve every commit from the repository
with_statsbooleanStats about each commit are added to the response
first_parentbooleanFollow only the first parent commit upon seeing a merge commit
orderenum (default | topo)List commits in order
trailersbooleanParse and include Git trailers for every commit
pagenumberPage number for pagination (default: 1)
per_pagenumberNumber of items per page (max: 100, default: 20)

get_commit

๐Ÿ“– Read-only

Get details of a specific commit

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
shastringโœ“The commit hash or name of a repository branch or tag
statsbooleanInclude commit stats

get_commit_diff

๐Ÿ“– Read-only

Get changes/diffs of a specific commit

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
shastringโœ“The commit hash or name of a repository branch or tag
full_diffbooleanWhether to return the full diff or only first page (default: false)

get_file_blame

๐Ÿ“– Read-only

Get git blame for a file at a given ref. Each entry maps a contiguous range of source lines to the commit that last changed them (id, author, authored_date, message). Use range_start/range_end to limit blame to specific lines.

Parameters

ParameterTypeRequiredDescription
project_idstringProject ID or complete URL-encoded path to project
file_pathstringโœ“The full path of the file to blame, relative to repo root
refstringโœ“The name of branch, tag or commit (required by GitLab blame API)
range_startintegerFirst line of the blame range (inclusive, 1-based). Both range[start] and range[end] must be set together.
range_endintegerLast line of the blame range (inclusive, 1-based). Both range[start] and range[end] must be set together.

list_commit_statuses

๐Ÿ“– Read-only

List statuses for a commit

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
shastringโœ“The commit hash or name of a repository branch or tag
refstringFilter statuses by Git ref
stagestringFilter statuses by build stage
namestringFilter statuses by status name or context
pipeline_idnumberFilter statuses by pipeline ID
order_byenum (id | pipeline_id)Field to order statuses by
sortenum (asc | desc)Sort direction
allbooleanReturn all statuses, not only latest ones
pagenumberPage number for pagination (default: 1)
per_pagenumberNumber of items per page (max: 100, default: 20)

create_commit_status

โœ๏ธ Writes

Create or update the status of a commit

Parameters

ParameterTypeRequiredDescription
project_idstringโœ“Project ID or complete URL-encoded path to project
shastringโœ“The commit hash to set the status on
stateenum (pending | running | success | failed | canceled | skipped)โœ“Commit status state
refstringThe branch or tag ref
namestringStatus name. GitLab defaults to 'default' when omitted.
contextstringAlias for name. Provide either name or context, not both.
target_urlstringTarget URL associated with this status
descriptionstringShort status description
coveragenumberTotal code coverage for this status
pipeline_idnumberPipeline ID to attach the status to