1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/content/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository.md

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 %}.
/articles/deleting-branches-in-a-pull-request/
/articles/creating-and-deleting-branches-within-your-repository
free-pro-team enterprise-server github-ae
* * *

Creating a branch

{% data reusables.repositories.navigate-to-repo %}

  1. 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: Branches link on overview page
  2. Click the branch selector menu. branch selector menu
  3. Type a unique name for your new branch, then select Create branch. branch creation text box

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 %}

  1. Scroll to the branch that you want to delete, then click {% octicon "trashcan" aria-label="The trashcan icon to delete the branch" %}. 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."

Further reading