branches

List all repository branches

Lists all repository branches from a specified project, sorted alphabetically by name. Search by name, or use regular expressions to find specific branch patterns. Returns detailed information about the branch, including its protection status, merge status, and commit details.

get/api/v4/projects/{id}/repository/branches

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idstring required

The ID or URL-encoded path of the project

Query parameters

pageinteger

Current page number

per_pageinteger

Number of items per page

searchstring

Return list of branches matching the search criteria

regexstring

Return list of branches matching the regex

sort'name_asc' | 'updated_asc' | 'updated_desc'

Return list of branches sorted by the given field

page_tokenstring

Name of branch to start the pagination from

Response

List all repository branches

namestring required
mergedboolean required
protectedboolean required
developers_can_pushboolean required
developers_can_mergeboolean required
can_pushboolean required
defaultboolean required
web_urlstring required

Example response

[
  {
    "name": "master",
    "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"
    },
    "merged": true,
    "protected": true,
    "developers_can_push": true,
    "developers_can_merge": true,
    "can_push": true,
    "default": true,
    "web_url": "https://gitlab.example.com/Commit921/the-dude/-/tree/master"
  }
]

Changes

No recorded changes to this operation across all 5 revisions of this API.