2.8 KiB
title, intro, redirect_from, versions
| title | intro | redirect_from | versions | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Creating and deleting branches within your repository | You can create or delete branches directly on {% data variables.product.product_name %}. |
|
|
Creating a branch
{% data reusables.repositories.navigate-to-repo %}
- Optionally, if you want to create your new branch from a branch other than the default branch for the repository, click {% octicon "git-branch" aria-label="The branch icon" %} NUMBER branches then choose another branch:

- Click the branch selector menu.

- Type a unique name for your new branch, then select Create branch.

Deleting a branch
{% data reusables.pull_requests.automatically-delete-branches %}
{% note %}
Note: If the branch you want to delete is the repository's default branch, you must choose a new default branch before deleting the branch. For more information, see "Changing the default branch."
{% endnote %}
If the branch you want to delete is associated with an open pull request, you must merge or close the pull request before deleting the branch. For more information, see "Merging a pull request" or "Closing a pull request."
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.navigate-to-branches %}
- Scroll to the branch that you want to delete, then click {% octicon "trashcan" aria-label="The trashcan icon to delete the branch" %}.

{% if currentVersion == "free-pro-team@latest" or currentVersion == "github-ae@latest" or currentVersion ver_gt "enterprise-server@2.21" %} {% data reusables.pull_requests.retargeted-on-branch-deletion %} {% endif %} For more information, see "About branches."