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

Ori*_*ent 60 git github bitbucket

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

我尝试着:

# 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://git@bitbucket.org/user/reponame.git
 ! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'ssh://git@bitbucket.org/user/reponame.git' 
Run Code Online (Sandbox Code Playgroud)

我也试过了

git push bb :master
Run Code Online (Sandbox Code Playgroud)

但这一切都行不通.

Von*_*onC 118

注意:对于BitBucket,您可以通过访问repo的设置以及更改" Main branch"组合框中的分支来更改默认分支.

BitBucket上的主要分支

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


Wou*_*r J 55

选项设置块中点击设置页面(好吧,只需点击你的github repo页面上的Settings选项卡),你就可以更改默认分支(你需要在github上有另一个默认分支) .

在github上更改默认分支

完成后,您可以删除它:

$ git push bb :master
Run Code Online (Sandbox Code Playgroud)

  • 您必须是管理员才能进行此类更改。 (2认同)