git 如何在 GitHub.com 中设置默认分支?

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

How to set the default branch in GitHub.com?

gitversion-controlgithubrepository

提问by B Seven

I found the following info, but didn't find where to go to access it. Didn't find it in account settings. Is there a repo settings page? Do you have to be the repo owner?

我找到了以下信息,但没有找到去哪里访问它。账户设置里没找到。有回购设置页面吗?您必须是回购所有者吗?

https://github.com/blog/421-pick-your-default-branch

https://github.com/blog/421-pick-your-default-branch

How to set the default branch on github.comwhen I go to browse commits.

当我去浏览提交时如何在github.com上设置默认分支。

回答by nulltoken

Do you have to be the repo owner?

您必须是回购所有者吗?

Yes you do.

是的你是。

How to set the default branch on github.com when I go to browse commits.

当我去浏览提交时如何在 github.com 上设置默认分支。

If you fork the repository, you can change the default branch of yourfork, by clicking on the Settingsbutton (see below).

如果你用叉子叉库,您可以更改默认分支通过点击叉,设置按钮(见下文)。

This will allow you to pick your favorite branch as the default one for your own fork, but you'll have to keep your forked repository in sync with the upstream repository by yourself.

这将允许您选择您最喜欢的分支作为您自己的分支的默认分支,但您必须自己保持分支存储库与上游存储库同步。

settings

设置

Or you can directly jump to the following url https://github.com/{:user}/{:repo}/settings

或者你可以直接跳转到下面的url https://github.com/{:user}/{:repo}/settings

回答by Matija

Simple just log into your GitHub account and on the far right side in the navigation menu choose Settings, in the Settings Tabchoose Default Branchand return back to main page of your repository that did the trick for me.

简单只需登录您的 GitHub 帐户,然后在导航菜单的最右侧选择Settings,在Settings 选项卡中选择Default Branch并返回到您的存储库的主页,这对我有用。

回答by sage

Initially, I confirmed the "Default Branch" was 'master' even though clones were defaulting to another branch 'stackato'. Here's what I tried...

最初,我确认“默认分支”是“主”,即使克隆默认为另一个分支“stackato”。这是我尝试过的...

Change and change back

改变和改变回来

  1. The main/top option in the settings is titled "Options" and I changed my "Default Branch" from 'master' (what I wanted) to a third branch name that I did not want, but different from 'stackato' that was appearing when I cloned
  2. I selected "Collaborators" from the menu on the left
  3. I selected "Options" again from the menu on the left and confirmed that my selection from #1 was still active (telling me it had presumably auto-saved)
  4. I changed my "Default Branch" back to 'master'
  5. I selected "Collaborators" again from the menu on the left
  6. I selected "Options" one last time from the menu on the left and confirmed that my 'master' was still active (telling me it had presumably auto-saved)
  1. 设置中的主要/顶部选项标题为“选项”,我将“默认分支”从“master”(我想要的)更改为我不想要的第三个分支名称,但与出现的“stackato”不同当我克隆
  2. 我从左侧的菜单中选择了“协作者”
  3. 我再次从左侧的菜单中选择了“选项”,并确认我从 #1 中的选择仍然处于活动状态(告诉我它可能已自动保存)
  4. 我将我的“默认分支”改回“master”
  5. 我再次从左侧的菜单中选择了“协作者”
  6. 我最后一次从左侧菜单中选择了“选项”,并确认我的“主人”仍然处于活动状态(告诉我它大概是自动保存的)

and/or Wait a while

和/或稍等片刻

I cannot rule out the possibility that it just took some time for my change to 'propagate'.

我不能排除我的更改需要一些时间才能“传播”的可能性。

回答by SomeAnonymousPerson

This is pretty easy from the github interface. You just need to go into the repository where you want to change de default branch and click on settings on the right side of the page:

从 github 界面这很容易。您只需要进入要更改默认分支的存储库,然后单击页面右侧的设置:

enter image description here

在此处输入图片说明

and then, inside there you just need to change the branch as you would like to:

然后,在那里,您只需要根据需要更改分支:

enter image description here

在此处输入图片说明