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โ โ๏ธ Writesget_branchโ ๐ Read-onlylist_branchesโ ๐ Read-onlydelete_branchโ โ๏ธ Writeslist_protected_branchesโ ๐ Read-onlyget_protected_branchโ ๐ Read-onlyprotect_branchโ โ๏ธ Writesunprotect_branchโ โ๏ธ Writesupdate_default_branchโ โ๏ธ Writeslist_commitsโ ๐ Read-onlyget_commitโ ๐ Read-onlyget_commit_diffโ ๐ Read-onlyget_file_blameโ ๐ Read-onlylist_commit_statusesโ ๐ Read-onlycreate_commit_statusโ โ๏ธ Writes
create_branch
โ๏ธ Writes
Create a new branch
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
branch | string | โ | Name for the new branch |
ref | string | Source branch/commit for new branch |
get_branch
๐ Read-only
Get branch details (commit, protection status)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
branch_name | string | โ | Name of the branch |
list_branches
๐ Read-only
List branches in project with search filter
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
search | string | Search term to filter branches by name | |
page | number | Page number for pagination (default: 1) | |
per_page | number | Number of items per page (max: 100, default: 20) |
delete_branch
โ๏ธ Writes
Delete branch from project
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
branch_name | string | โ | Name of the branch to delete |
list_protected_branches
๐ Read-only
List protected branches in a project, supports search filter
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
search | string | Search term to filter protected branches by name | |
page | number | Page number for pagination (default: 1) | |
per_page | number | Number 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
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
branch_name | string | โ | Name of the protected branch |
protect_branch
โ๏ธ Writes
Protect a repository branch (set push/merge/unprotect access levels)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | Project ID or complete URL-encoded path to project | |
branch_name | string | โ | Branch name or wildcard pattern to protect |
name | string | Deprecated alias for branch_name; prefer branch_name for consistency | |
push_access_level | integer | Access level for pushing (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted. | |
merge_access_level | integer | Access level for merging (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted. | |
unprotect_access_level | integer | Access level for unprotecting (0=No access, 30=Developer, 40=Maintainer, 60=Admin). GitLab default applies when omitted. | |
allow_force_push | boolean | Allow force push to the protected branch. Default: false | |
code_owner_approval_required | boolean | Require code owner approval before merging (PREMIUM). Default: false |
unprotect_branch
โ๏ธ Writes
Remove protection from a previously protected branch
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
branch_name | string | โ | Name of the protected branch to unprotect |
update_default_branch
โ๏ธ Writes
Change the default branch of a project
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
default_branch | string | โ | The new default branch name for the project |
list_commits
๐ Read-only
List repository commits with filtering options
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
ref_name | string | The name of a repository branch, tag or revision range, or if not given the default branch | |
since | string | Only commits after or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ | |
until | string | Only commits before or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ | |
path | string | The file path | |
author | string | Search commits by commit author | |
all | boolean | Retrieve every commit from the repository | |
with_stats | boolean | Stats about each commit are added to the response | |
first_parent | boolean | Follow only the first parent commit upon seeing a merge commit | |
order | enum (default | topo) | List commits in order | |
trailers | boolean | Parse and include Git trailers for every commit | |
page | number | Page number for pagination (default: 1) | |
per_page | number | Number of items per page (max: 100, default: 20) |
get_commit
๐ Read-only
Get details of a specific commit
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
sha | string | โ | The commit hash or name of a repository branch or tag |
stats | boolean | Include commit stats |
get_commit_diff
๐ Read-only
Get changes/diffs of a specific commit
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
sha | string | โ | The commit hash or name of a repository branch or tag |
full_diff | boolean | Whether 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
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | Project ID or complete URL-encoded path to project | |
file_path | string | โ | The full path of the file to blame, relative to repo root |
ref | string | โ | The name of branch, tag or commit (required by GitLab blame API) |
range_start | integer | First line of the blame range (inclusive, 1-based). Both range[start] and range[end] must be set together. | |
range_end | integer | Last 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
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
sha | string | โ | The commit hash or name of a repository branch or tag |
ref | string | Filter statuses by Git ref | |
stage | string | Filter statuses by build stage | |
name | string | Filter statuses by status name or context | |
pipeline_id | number | Filter statuses by pipeline ID | |
order_by | enum (id | pipeline_id) | Field to order statuses by | |
sort | enum (asc | desc) | Sort direction | |
all | boolean | Return all statuses, not only latest ones | |
page | number | Page number for pagination (default: 1) | |
per_page | number | Number of items per page (max: 100, default: 20) |
create_commit_status
โ๏ธ Writes
Create or update the status of a commit
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project_id | string | โ | Project ID or complete URL-encoded path to project |
sha | string | โ | The commit hash to set the status on |
state | enum (pending | running | success | failed | canceled | skipped) | โ | Commit status state |
ref | string | The branch or tag ref | |
name | string | Status name. GitLab defaults to 'default' when omitted. | |
context | string | Alias for name. Provide either name or context, not both. | |
target_url | string | Target URL associated with this status | |
description | string | Short status description | |
coverage | number | Total code coverage for this status | |
pipeline_id | number | Pipeline ID to attach the status to |