Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-10-12. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Creating and deleting branches within your repository

You can create or delete branches directly on GitHub Enterprise Server.

Creating a branch

You can create a branch in different ways on GitHub Enterprise Server.

Note: You can only create a branch in a repository to which you have push access.

Creating a branch using the branch dropdown

  1. On your GitHub Enterprise Server instance, navigate to the main page of the repository.
  2. Optionally, if you want to create the new branch from a branch other than the default branch of the repository, click Branches then choose another branch. Branches link on overview page
  3. Click the branch selector menu. branch selector menu
  4. Type a unique name for your new branch, then select Create branch. branch creation text box

Deleting a branch

您可让头部分支在仓库中的拉取请求合并后自动� 除。 有关详细信息,请参阅“管理分支的自动� 除”。

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."

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."

  1. On your GitHub Enterprise Server instance, navigate to the main page of the repository.
  2. 在文件列表上方,单击 “分支”。 概述页面上的分支链接
  3. Scroll to the branch that you want to delete, then click . delete the branch

如果您在拉取请求合并后� 除头部分支,GitHub 会检查将已� 除分支指定为基础分支的同一仓库中的任何开放拉取请求。 GitHub 将自动更新任何此类拉取请求,将其基础分支更改为合并的拉取请求的基础分支。 For more information, see "About branches."

Further reading