git 删除远程主分支,由于是当前分支而被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14040754/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:09:55  来源:igfitidea点击:

Deleting remote master branch, refused due to being current branch

gitgithubbitbucket

提问by Tomilov Anatoliy

How do I delete a remote master branch from GitHub/Bitbucket?

如何从 GitHub/Bitbucket 删除远程主分支?

I'm trying:

我想:

# git push bb --delete master
remote: bb/acl: user is allowed. accepted payload.[K
remote: error: refusing to delete the current branch: refs/heads/master[K
To ssh://[email protected]/user/reponame.git
 ! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'ssh://[email protected]/user/reponame.git' 

Also I tried

我也试过

git push bb :master

But all this is not work.

但这一切都行不通。

回答by VonC

Note: for BitBucket, you would change the default branch by accessing the settings of your repo, and changing the branch at the "Main branch" combo box.

注意:对于BitBucket,您可以通过访问存储库的设置来更改默认分支,并在“ Main branch”组合框中更改分支。

main branch on BitBucket

BitBucket 上的主要分支

Once the main branch is no longer master, then you can push and remove master.

一旦主分支不再是 master ,那么您可以推送和删除 master

回答by Wouter J

In the settingsblock on the optionstap in the settingspage (well, just click on the Settingstab on your github repo page), you are able to change the default branch (you need to have the other default branch on github as well).

设置页面中选项设置块中(好吧,只需单击github 存储库页面上的设置选项卡),您就可以更改默认分支(您还需要在 github 上拥有另一个默认分支) .

change default branch on github

更改 github 上的默认分支

After you have done that, you are able to remove it:

完成后,您可以将其删除:

$ git push bb :master