如何从 bitbucket 中删除 git 远程主机?

How to remove the git remote master from bitbucket?

在一个git项目中,我在一个分支中做了一些重构,现在这个分支应该是一个新项目。 我将此项目从 github 移至 bitbucket。现在我想删除旧的master,让重构分支成为新的master。

我尝试删除主控:

$ git branch -D master
Deleted branch master (was a947288).
$ git push origin :master
remote: error: refusing to delete the current branch: refs/heads/master
 ! [remote rejected] master (deletion of the current branch prohibited)

在 bitbucket 前端我也无法删除 master。那我怎么能做到呢?或者我是否必须创建一个新项目并将重构分支推送到它的主分支?

您必须更改 bibucket 的主分支才能删除它。 只要 master 是主分支,bitbucket 就会阻止您这样做(这是有道理的)。

在 Bitbucket 中 UI:

  • Select 存储库
  • Select 管理
  • 在存储库详细信息中,设置主分支

重复:

  • Deleting remote master branch, refused due to being current branch
  • I can't delete a remote master branch on git

当您推送删除时,you must first change the default branch (on GitHub) 到您的新分支。
这意味着您必须先将新分支推送到 GitHub 才能 select 将其作为默认分支。

然后你可以删除 GitHub 上的 master。

同样的想法applies on BitBucket:

  1. Select the repository
  2. Select Administration
  3. In Repository Details, set Main branch