我不小心将我的本地master推到了gitlab上的一个名为origin的分支,现在它是默认的。是否有办法重命名这个分支或将一个新的主分支设置为master?
首先,我需要使用ssh远程访问服务器。如果有人有一个非ssh的方式,请张贴。
我在
cd /var/opt/gitlab/git-data/repositories/group-name/project-name.git
used
git branch
看到错误的活动分支
git symbolic-ref HEAD refs/heads/master
要将master更改为名为master的分支,请使用web界面和“git分支”进行确认。
在最新的GitLab社区版9.2.2版本中。
你必须点击位于标签页最右边的“设置”标签 面板后打开项目。 在“设置”下,你会看到“默认分支”下拉菜单 这将为您提供存储库的所有分支。选择所需的分支。 向下滚动,点击绿色的“保存更改”按钮 《阿凡达计划》之后。
请参考下图:
对于GitLab 11.5.0-ee,请转到 https://gitlab.com/ <用户名> / <项目名称> /设置/库。
你应该看到:
默认的分支
选择要设置为此项目默认值的分支。所有合并请求和提交都将自动针对该分支执行,除非您指定了另一个分支。
单击“展开”,选择一个分支,单击“保存更改”。
参见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.
推荐文章
- 在gitlab上被拒绝许可(公钥)
- 我如何将工件传递到另一个阶段?
- 在gitlab中更改默认分支
- 使用GitLab令牌进行克隆,无需身份验证
- Git推送错误,预接收钩子被拒绝
- 从GitLab转移git存储库到GitHub -我们可以,如何和陷阱(如果有的话)?
- 如何删除一个Gitlab项目?
- 如何查看GitLab的版本?
- GitLab remote: HTTP Basic: Access denied and fatal认证
- 修复GitLab错误:“您不允许将代码推送到这个项目上受保护的分支”?
- 服务器证书验证失败。CAfile: /etc/ssl/certs/ca-certificates。crt CRLfile:无
- 拉取请求vs合并请求