Skip to main content

List Branches

Returns a list of all open branches within the specified repository. Results will be in the order the source control manager returns them. Branches support filtering and sorting that can be used to search for specific branches.

By default, results will be in the order the underlying source control system returns them and identical to the ordering one sees when running "$ git branch --list". Note that this follows simple lexical ordering of the ref names.

This can be undesirable as it does apply any natural sorting semantics, meaning for instance that tags are sorted ["v10", "v11", "v9"] instead of ["v9", "v10", "v11"].

Sorting can be changed using the ?q= query parameter. When using ?q=name to explicitly sort on ref name, Bitbucket will apply natural sorting and interpret numerical values as numbers instead of strings.

External Documentation

To learn more, visit the Bitbucket documentation.

Parameters

ParameterDescription
Query StringQuery string to narrow down the response as perfiltering and sorting.
Repo SlugThis can either be the repository slug or the UUID of the repository,surrounded by curly-braces, for example: {repository UUID}.
SortField by which the results should be sorted as perfiltering and sorting. The namefield is handled specially for branches in that, if specified as the sort field, ituses a natural sort order instead of the default lexicographical sort order. For example,it will return ['branch1', 'branch2', 'branch10'] instead of ['branch1', 'branch10', 'branch2'].
Workspace SlugThis can either be the workspace ID (slug) or the workspace UUIDsurrounded by curly-braces, for example: {workspace UUID}.

Example Output

{
"next": "Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.",
"page": 0,
"pagelen": 0,
"previous": "Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.",
"size": 0,
"values": [
{
"default_merge_strategy": "The default merge strategy for pull requests targeting this branch.",
"links": {
"commits": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"merge_strategies": [
"string"
],
"name": "The name of the ref.",
"target": {
"author": {
"raw": "The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.",
"type": "string",
"user": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
},
"date": "date-time",
"hash": "[0-9a-f]{7,}?",
"message": "string",
"parents": [
null
],
"participants": [
{
"approved": false,
"participated_on": "The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.",
"role": "string",
"state": "string",
"type": "string",
"user": {
"account_id": "The user's Atlassian account ID.",
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"is_staff": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
}
}
],
"repository": {
"created_on": "date-time",
"description": "string",
"fork_policy": "\nControls the rules for forking this repository.\n\n* **allow_forks**: unrestricted forking\n* **no_public_forks**: restrict forking to private forks (forks cannot\n be made public later)\n* **no_forks**: deny all forking\n",
"full_name": "The concatenation of the repository owner's username and the slugified name, e.g. \"evzijst/interruptingcow\". This is the same string used in Bitbucket URLs.",
"has_issues": false,
"has_wiki": false,
"is_private": false,
"language": "string",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"clone": [
{
"href": "uri",
"name": "string"
}
],
"commits": {
"href": "uri",
"name": "string"
},
"downloads": {
"href": "uri",
"name": "string"
},
"forks": {
"href": "uri",
"name": "string"
},
"hooks": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"pullrequests": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
},
"watchers": {
"href": "uri",
"name": "string"
}
},
"name": "string",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"project": {
"created_on": "date-time",
"description": "string",
"has_publicly_visible_repos": false,
"is_private": false,
"key": "The project's key.",
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
}
},
"name": "The name of the project.",
"owner": {
"account_status": "The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.",
"created_on": "date-time",
"display_name": "string",
"has_2fa_enabled": false,
"links": {
"avatar": {
"href": "uri",
"name": "string"
},
"followers": {
"href": "uri",
"name": "string"
},
"following": {
"href": "uri",
"name": "string"
},
"html": {
"href": "uri",
"name": "string"
},
"repositories": {
"href": "uri",
"name": "string"
},
"self": {
"href": "uri",
"name": "string"
}
},
"nickname": "Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.",
"type": "string",
"username": "^[a-zA-Z0-9_\\-]+$",
"uuid": "string",
"website": "string"
},
"type": "string",
"updated_on": "date-time",
"uuid": "The project's immutable id."
},
"scm": "string",
"size": 0,
"type": "string",
"updated_on": "date-time",
"uuid": "The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user."
},
"summary": {
"html": "The user's content rendered as HTML.",
"markup": "The type of markup language the raw content is to be interpreted in.",
"raw": "The text as it was typed by a user."
},
"type": "string"
},
"type": "string"
}
]
}

Workflow Library Example

List Branches with Bitbucket and Send Results Via Email

Workflow LibraryPreview this Workflow on desktop