branches
Accessed as client.repos.branches; the async client mirrors it.
ReposBranches
The repos.branches namespace.
create
create(
owner: str, repo: str, *, new_branch_name: str, old_branch_name: str | None = None, old_ref_name: str | None = None
) -> Branch
Create a branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
new_branch_name
|
str
|
Name of the branch to create |
required |
old_branch_name
|
str | None
|
Deprecated: true Name of the old branch to create from |
None
|
old_ref_name
|
str | None
|
Name of the old branch/tag/commit to create from |
None
|
Returns:
| Type | Description |
|---|---|
Branch
|
Branch. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
ConflictError
|
|
PayloadTooLargeError
|
|
LockedError
|
|
Operation ID: repoCreateBranch
delete
delete(owner: str, repo: str, branch: str) -> None
Delete a specific branch from a repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
branch to delete |
required |
Returns:
| Type | Description |
|---|---|
None
|
No content. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
LockedError
|
|
Operation ID: repoDeleteBranch
get
get(owner: str, repo: str, branch: str) -> Branch
Retrieve a specific branch from a repository, including its effective branch protection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
branch to get |
required |
Returns:
| Type | Description |
|---|---|
Branch
|
Branch. |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
|
Operation ID: repoGetBranch
list
list(owner: str, repo: str, *, page: int | None = None, limit: int | None = None) -> Paginated[Branch]
List a repository's branches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
page
|
int | None
|
1-based page to start iteration at. |
None
|
limit
|
int | None
|
Page size; the instance caps it server-side. |
None
|
Returns:
| Type | Description |
|---|---|
Paginated[Branch]
|
BranchList. |
Operation ID: repoListBranches
update
update(owner: str, repo: str, branch: str, *, name: str) -> None
Update a branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
name of the branch |
required |
name
|
str
|
New branch name |
required |
Returns:
| Type | Description |
|---|---|
None
|
No content. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
UnprocessableEntityError
|
|
Operation ID: repoUpdateBranch
AsyncReposBranches
The repos.branches namespace.
create
create(
owner: str, repo: str, *, new_branch_name: str, old_branch_name: str | None = None, old_ref_name: str | None = None
) -> Branch
Create a branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
new_branch_name
|
str
|
Name of the branch to create |
required |
old_branch_name
|
str | None
|
Deprecated: true Name of the old branch to create from |
None
|
old_ref_name
|
str | None
|
Name of the old branch/tag/commit to create from |
None
|
Returns:
| Type | Description |
|---|---|
Branch
|
Branch. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
ConflictError
|
|
PayloadTooLargeError
|
|
LockedError
|
|
Operation ID: repoCreateBranch
delete
delete(owner: str, repo: str, branch: str) -> None
Delete a specific branch from a repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
branch to delete |
required |
Returns:
| Type | Description |
|---|---|
None
|
No content. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
LockedError
|
|
Operation ID: repoDeleteBranch
get
get(owner: str, repo: str, branch: str) -> Branch
Retrieve a specific branch from a repository, including its effective branch protection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
branch to get |
required |
Returns:
| Type | Description |
|---|---|
Branch
|
Branch. |
Raises:
| Type | Description |
|---|---|
NotFoundError
|
|
Operation ID: repoGetBranch
list
list(owner: str, repo: str, *, page: int | None = None, limit: int | None = None) -> AsyncPaginated[Branch]
List a repository's branches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
page
|
int | None
|
1-based page to start iteration at. |
None
|
limit
|
int | None
|
Page size; the instance caps it server-side. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncPaginated[Branch]
|
BranchList. |
Operation ID: repoListBranches
update
update(owner: str, repo: str, branch: str, *, name: str) -> None
Update a branch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str
|
owner of the repo |
required |
repo
|
str
|
name of the repo |
required |
branch
|
str
|
name of the branch |
required |
name
|
str
|
New branch name |
required |
Returns:
| Type | Description |
|---|---|
None
|
No content. |
Raises:
| Type | Description |
|---|---|
ForbiddenError
|
|
NotFoundError
|
|
UnprocessableEntityError
|
|
Operation ID: repoUpdateBranch