About branches
Use a branch to isolate development work without affecting other branches in the repository. Each repository has one default branch, and can have multiple other branches. You can merge a branch into another branch using a pull request.
You can use branches to:
- Develop features
- Fix bugs
- Safely experiment with new ideas
For more information, see "Creating and deleting branches within your repository."
Once you're satisfied with the changes in your branch, you can open a pull request to merge your branch (the head branch) into another branch (the base branch). For more information, see "About pull requests."
You can also use a branch to publish a GitHub Pages site. For more information, see "What is GitHub Pages?"
You must have write access to a repository to create a branch, open a pull request, or delete and restore branches in a pull request. In repositories where you have owner or admin access, you can change the default branch. For more information, see "Access permissions on GitHub Enterprise" and "Managing branches in your repository."
Working with protected branches
Repository administrators can enable protections on a branch. If you're working on a branch that's protected, you won't be able to delete or force push to the branch. Repository administrators can additionally enable several other protected branch settings to enforce various workflows before a branch can be merged.
Note: If you're a repository administrator, you can merge pull requests on branches with branch protections enabled even if the pull request does not meet the requirements, unless branch protections have been set to "Include administrators."
To see if your pull request can be merged, look in the merge box at the bottom of the pull request's Conversation tab. For more information, see "About protected branches."
When a branch is protected:
- You won't be able to delete or force push to the branch.
- If required status checks are enabled on the branch, you won't be able to merge changes into the branch until all of the required CI tests pass. For more information, see "About status checks."
- If required pull request reviews are enabled on the branch, you won't be able to merge changes into the branch until all requirements in the pull request review policy have been met. For more information, see "Merging a pull request."
- If required review from a code owner is enabled on a branch, and a pull request modifies code that has an owner, a code owner must approve the pull request before it can be merged. For more information, see "About code owners."
- If required commit signing is enabled on a branch, you won't be able to push any commits to the branch that are not signed and verified. For more information, see "About commit signature verification" and "About required commit signing."
Further reading
- "About pull requests"
- "Branch" in the GitHub Glossary
- "Branches in a Nutshell" in the Git documentation