Skip to main content

branch

Overview

Namebranch
TypeResource
Idgithub.repos.branch

Fields

NameDatatypeDescription
namestring
_linksobject
commitobjectCommit
patternstring
protectedboolean
protectionobjectBranch Protection
protection_urlstring
required_approving_review_countinteger

Methods

NameAccessible byRequired ParamsDescription
get_branchSELECTbranch, owner, repo
mergeEXECowner, repo, data__base, data__head
merge_upstreamEXECowner, repo, data__branchSync a branch of a forked repository to keep it up-to-date with the upstream repository.
rename_branchEXECbranch, owner, repo, data__new_nameRenames a branch in a repository.

Note: Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "Renaming a branch".

The permissions required to use this endpoint depends on whether you are renaming the default branch.

To rename a non-default branch:

Users must have push access.
GitHub Apps must have the contents:write repository permission.

To rename the default branch:

Users must have admin or owner permissions.
GitHub Apps must have the administration:write repository permission.