List Branches
List all branches in a repository.Path Parameters
Owner of the repository
Name of the repository
Query Parameters
Page number of results (1-based)
Page size of results
Response
Returns an array of branch objects.Branch name
Whether the branch is protected
Number of required approvals for PRs to this branch
Whether status checks are enabled
List of required status check contexts
Whether the current user can push to this branch
Whether the current user can merge to this branch
Name of the effective branch protection rule
Get Branch
Retrieve a specific branch from a repository, including its effective branch protection.Path Parameters
Owner of the repository
Name of the repository
Name of the branch to retrieve
Create Branch
Create a new branch in a repository.Path Parameters
Owner of the repository
Name of the repository
Request Body
Name of the branch to create
Name of the reference (branch/tag/commit SHA) to create the branch from. If not specified, uses the default branch.
Response
Returns the created branch object.The repository must not be empty, and branch names must follow Git reference naming conventions.
Update Branch
Update a branch reference to point to a new commit.Path Parameters
Owner of the repository
Name of the repository
Name of the branch to update
Request Body
New commit SHA to point the branch to
Expected current commit SHA (for safety check)
Force update even if it’s not a fast-forward
Rename Branch
Rename an existing branch.Path Parameters
Owner of the repository
Name of the repository
Current name of the branch
Request Body
New name for the branch
Renaming protected branches or the default branch requires admin or owner permissions.
Delete Branch
Delete a specific branch from a repository.Path Parameters
Owner of the repository
Name of the repository
Name of the branch to delete
Branch Protection
List Branch Protections
List all branch protection rules for a repository.Get Branch Protection
Get a specific branch protection rule.Create Branch Protection
Create a new branch protection rule.Request Body
Name of the branch protection rule (can be branch name or pattern like
release/*)Priority of this rule (higher priority rules are matched first)
Allow push to this branch
Restrict push to whitelisted users/teams
Usernames allowed to push
Team names allowed to push
Restrict merge to whitelisted users/teams
Usernames allowed to merge
Team names allowed to merge
Require status checks to pass before merging
Required status check contexts that must pass
Number of required approvals before merging
Only count approvals from whitelisted users/teams
Block merge if there are rejected reviews
Dismiss approvals when new commits are pushed
Require all commits to be signed
Block merge if branch is not up to date with base
Update Branch Protection
Edit an existing branch protection rule. Only provided fields will be changed.Delete Branch Protection
Delete a branch protection rule.Merge Upstream
For forked repositories, merge changes from the upstream repository.Request Body
Branch to merge into (typically the default branch)
Only perform fast-forward merge
This endpoint only works for repositories that are forks. The merge type can be
merge, fast-forward, or already-up-to-date.