Change Default branch in gitlab
我不小心将本地主服务器推送到了gitlab上一个名为origin的分支,现在它是默认分支。是否可以重命名此分支或将新的master分支设置为master?
在8.0中,这似乎已移到项目中。如果打开项目并转到右侧的齿轮图标,则"编辑项目"可以为项目设置默认分支。
要在GitLab中更改默认分支,请执行以下操作:
1.设置>常规>常规项目设置>展开
2.默认分支>更改项目的默认分支
3.保存更改
在GitLab企业版12.2.0-pre中,
您必须使用以下命令:

对于gitlab v10(截至2018年9月),此内容已移至设置->存储库->默认分支
如@Luke所述,此设置自4/1/2021起仍然有效。
要在Gitlab 7.7.2中更改默认分支:
- 点击左侧栏中的设置
- 将默认分支更改为所需的分支
- 单击保存更改。
在最新的GitLab社区版9.2.2中:
打开项目后的面板。
这将为您提供存储库的所有分支。选择所需的分支。
在"阿凡达计划"之后。
请参考下图:
在Gitlab版本v11.4.4-ee中,您可以:
点击我
另请参见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 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 namedmaster .Git version 2.31.0 (scheduled for release March 15, 2021) will change the default branch name in Git from
master tomain .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 11.5.0-ee,请转到
您应该看到:
选择要设置为该项目默认值的分支。除非您指定其他合并请求和提交,否则将自动对此分支进行所有合并请求和提交。
单击"展开",选择一个分支,然后单击"保存更改"。
在Gitlab CE 9.0中,您可以从存储库标题中的"设置"选项卡更改默认分支。
首先,我需要使用ssh远程访问服务器。如果某人有非ssh的方法,请发布。
我在
找到了裸存储库
1 | cd /var/opt/gitlab/git-data/repositories/group-name/project-name.git |
二手
1 | git branch |
查看错误的活动分支
1 | git symbolic-ref HEAD refs/heads/master |
将主节点更改为称为master的分支,然后使用Web界面和" git分支"进行确认。