git 如何更改 BitBucket 中的主分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37550492/
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-19 12:02:09  来源:igfitidea点击:

How to change the main branch in BitBucket?

gitbitbucket

提问by Maik

I have a repo on bitbucket with two branches. First branch is master with a fake content, then I have another one called trunk with the correct content.

我有一个关于 bitbucket 的 repo,有两个分支。第一个分支是具有虚假内容的 master,然后我有另一个名为 trunk 的具有正确内容的分支。

I would like to change the main branch to trunk (actually is master). I found that in the repo adminsitration are on bitbucket web I could change this but I couldn't.

我想把主分支改成trunk(其实是master)。我发现在 repo adminsitration 是在 bitbucket web 上我可以改变它,但我不能。

Finally I would like to understand if is possible to do this through terminal from my local repo.

最后,我想了解是否可以通过本地存储库的终端执行此操作。

Maybe an easy thing is to delete contents from master and merge trunk into master and the delete trunk but I neither know how to do this.

也许一件简单的事情是从 master 中删除内容并将主干合并到 master 和删除主干中,但我不知道该怎么做。

回答by 030

  1. Repositories
  1. 存储库

enter image description here

在此处输入图片说明

  1. Select repository
  2. Settings
  1. 选择存储库
  2. 设置

enter image description here

在此处输入图片说明

  1. Main branch: master
  1. 主枝: master

enter image description here

在此处输入图片说明

  1. Save repository details
  1. Save repository details

enter image description here

在此处输入图片说明

回答by Destrif

With two branches named trunkand master, change master to the HEAD of the repository and delete trunk:

使用两个名为trunkand 的分支master,将 master 更改为存储库的 HEAD 并删除trunk

git symbolic-ref HEAD refs/heads/master
git branch -d trunk

From:

从:

https://answers.atlassian.com/questions/280944/how-to-change-main-branch-in-bitbucket

https://answers.atlassian.com/questions/280944/how-to-change-main-branch-in-bitbucket

回答by Vishal Kamat

You can merge the trunk into master (you may have to force it) and then delete the trunk

您可以将主干合并到主干(您可能必须强制它)然后删除主干

git checkout master
git merge trunk