如何从 bitbucket 中删除 git remote master?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32135648/
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
How to remove the git remote master from bitbucket?
提问by s.meissner
In a git project I did some refactoring in a branch and now this branch should be a new project. I moved this project from github to bitbucket. Now I want to delete the old master and make the refactoring branch the new master.
在一个 git 项目中,我在一个分支中进行了一些重构,现在这个分支应该是一个新项目。我把这个项目从 github 移到了 bitbucket。现在我想删除旧的 master 并使重构分支成为新的 master。
I tried to delete the 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)
In the bitbucket frontend I couldn't delete the master neither. So how could I achive that? Or do I have to create a new project and push the refactoring branch into its master?
在 bitbucket 前端,我也无法删除 master。那我怎么能做到呢?或者我是否必须创建一个新项目并将重构分支推送到其主分支?
回答by Cyril Gandon
You have to change the main branch of bibucket before being able to delete it.
As long as master
is the main branch, bitbucket will prevent you to do so (which make sense).
您必须先更改 bibucket 的主分支,然后才能删除它。只要master
是主分支,bitbucket 就会阻止你这样做(这是有道理的)。
In Bitbucket UI:
在 Bitbucket 用户界面中:
- Select the repository
- Select Administration
- In Repository Details, set Main branch
- 选择存储库
- 选择管理
- 在 Repository Details 中,设置 Main 分支
Duplicates :
重复:
回答by VonC
When you are pushing a deletion, you must first change the default branch (on GitHub)to your new branch.
That means you must have first push your new branch on GitHub in order to select it as default branch.
当您推送删除时,您必须首先将默认分支(在 GitHub 上)更改为您的新分支。
这意味着您必须首先在 GitHub 上推送您的新分支才能将其选为默认分支。
Then you can delete master on GitHub.
然后你可以在 GitHub 上删除 master。
The same idea applies on BitBucket:
同样的想法适用于 BitBucket:
- Select the repository
- Select Administration
- In Repository Details, set Main branch
- 选择存储库
- 选择管理
- 在 Repository Details 中,设置 Main 分支