我需要删除一个主分支,但事实证明这很难。我只想清理那个分支并开始新的。我正在从开发分支中删除。我希望 GitHub 上的 master 是干净的。
# git push origin --delete master
> To https://github.com/mymasterb.git ! [remote rejected] master
> (deletion of the current branch prohibited) error: failed to push some
> refs to 'https://github.com/mymaster.git'
我如何简单地从新开始我的主人?
最佳答案
如 Matthew Brett 在“Deleting your master branch”中所述,您需要更改 GitHub 存储库默认分支。
You need to go to the GitHub page for your forked repository, and click on the “Settings” button.
Click on the "Branches" tab on the left hand side. There’s a “Default branch” dropdown list near the top of the screen.
From there, select placeholder (where placeholder is the dummy name for your new default branch).
Confirm that you want to change your default branch.
Now you can do (from the command line):
git push origin :master
或者,自 2012 年以来,您可以 delete that same branch directly on GitHub :
那是 announced in Sept. 2013 ,在我最初写下那个答案的一年后。
For small changes like documentation fixes, typos, or if you’re just a walking software compiler, you can get a lot done in your browser without needing to clone the entire repository to your computer.
注意:对于 BitBucket,Tum报道 in the comments :
About the same for Bitbucket
Repo -> Settings -> Repository details -> Main branch
关于git - 我无法删除 git 上的远程主分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12208751/