我不小心将我的本地master推到了gitlab上的一个名为origin的分支,现在它是默认的。是否有办法重命名这个分支或将一个新的主分支设置为master?


当前回答

在Gitlab CE 9.0中,您可以从存储库头中的Settings选项卡更改默认分支。

其他回答

在8.0+版本中,它似乎被移到了项目中。如果你打开你的项目,转到右边的齿轮图标,然后“编辑项目”,你可以为项目设置默认的分支。

更改GitLab的默认分支: 1. 设置>常规>项目常规设置>展开 2. 更改项目默认分支 3.保存更改

要更改Gitlab 7.7.2中的默认分支:

单击左侧栏中的设置 将默认分支更改为所需的分支 单击“保存更改”。

设置 一般 项目一般设置

参见GitLab 13.6(2020年11月)

Customize the initial branch name for new projects within a group When creating a new Git repository, the first branch created is named master by default. In coordination with the Git project, broader community, and other Git vendors, GitLab has been listening to the development community’s feedback on determining a more descriptive and inclusive name for the default branch, and is now offering users options to change the name of the default branch name for their repositories. Previously, we shipped the ability to customize the initial branch name at the instance-level and as part of 13.6, GitLab now allows group administrators to configure the default branch name for new repositories created through the GitLab interface. See Documentation and Issue.


GitLab 13.9(2021年2月)

Git默认分支名称更改

Every Git repository has an initial branch. It’s the first branch to be created automatically when you create a new repository. By default, this initial branch is named master. Git version 2.31.0 (scheduled for release March 15, 2021) will change the default branch name in Git from master to main. In coordination with the Git project and the broader community, GitLab will be changing the default branch name for new projects on both our SaaS (GitLab.com) and self-managed offerings starting with GitLab 14.0. This will not affect existing projects. For more information, see the related epic and the Git mailing list discussion. Deprecation date: Apr 22, 2021


如前所述,在GitLab 13.11(2021年4月)中:

Git default branch name change Every Git repository has an initial branch. It’s the first branch to be created automatically when you create a new repository. By default, this initial branch is named master. Future Git versions will change the default branch name in Git from master to main. In coordination with the Git project and the broader community, GitLab will be changing the default branch name for new projects on both our SaaS (GitLab.com) and self-managed offerings starting with GitLab 14.0. This will not affect existing projects. GitLab has already introduced changes that allow users to change the default branch name both at the instance-level (for self-managed users) and at the group-level (for both SaaS and self-managed users). We encourage users to make use of these features to set default branch names on new projects. For more information, see the related epic and related blog post.