在 gitlab 中更改默认分支
Change Default branch in gitlab
我不小心把我本地的master推到了gitlab上一个叫origin的分支,现在是默认了。有没有办法重命名这个分支或者设置一个新的master分支为master?
首先,我需要使用 ssh 远程访问我的服务器。如果有人有非 ssh 方式,请 post。
我在
找到了我的裸存储库
cd /var/opt/gitlab/git-data/repositories/group-name/project-name.git
用过
git branch
看到错误的活动分支
git symbolic-ref HEAD refs/heads/master
将 master 更改为名为 master 的分支然后使用 Web 界面并"git branch"确认。
要更改Gitlab 7.7.2 中的默认分支:
- 点击左侧栏中的设置
- 将默认分支更改为所需的分支
- 点击保存更改。
在 8.0+ 中,它似乎已移入项目中。如果您打开您的项目并转到右侧的齿轮图标,那么"Edit Project"您可以为项目设置默认分支。
在 Gitlab CE 9.0 中,您可以从存储库 header 的“设置”选项卡更改默认分支。
在最新的 GitLab Community Edition 版本 9.2.2 中:
- 您必须单击位于选项卡最右侧的 'Settings' 选项卡
打开项目后的面板。
- 在 'Settings' 下,您将看到 'Default Branch' 部分下拉菜单
这将为您提供存储库的所有分支。 Select 所需的分支。
- 向下滚动点击绿色 'Save changes' 按钮
在 'Project Avatar'.
之后
请参考下图:
- 设置
- 一般
- 常规项目设置
要更改 GitLab 中的默认分支:
1. 设置 > 通用 > 通用项目设置 > 展开
2. 默认分支 > 更改项目默认分支
3. 保存更改
对于 gitlab v10+(截至 2018 年 9 月),这已移至设置-> 存储库-> 默认分支
如@Luke 所述,这在 4/1/2021
仍然有效
对于 GitLab 11.5.0-ee,转到
https://gitlab.com/<username>/<project name>/settings/repository
.
你应该看到:
Default Branch
Select 您要设置为该项目默认的分支。除非您指定一个不同的分支,否则所有合并请求和提交都将自动针对此分支进行。
单击展开,select 一个分支,然后单击保存更改。
在Gitlab v11.4.4-ee版本中,您可以:
- 设置
- 存储库
- 默认分支
设置 > 存储库 > 默认分支
在 GitLab Enterprise Edition 12.2.0-pre 中,您必须使用以下内容:
Setting
→ Repository
→ Default Branch
(展开它)并在此处更改默认分支
另见 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 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.
我不小心把我本地的master推到了gitlab上一个叫origin的分支,现在是默认了。有没有办法重命名这个分支或者设置一个新的master分支为master?
首先,我需要使用 ssh 远程访问我的服务器。如果有人有非 ssh 方式,请 post。
我在
找到了我的裸存储库cd /var/opt/gitlab/git-data/repositories/group-name/project-name.git
用过
git branch
看到错误的活动分支
git symbolic-ref HEAD refs/heads/master
将 master 更改为名为 master 的分支然后使用 Web 界面并"git branch"确认。
要更改Gitlab 7.7.2 中的默认分支:
- 点击左侧栏中的设置
- 将默认分支更改为所需的分支
- 点击保存更改。
在 8.0+ 中,它似乎已移入项目中。如果您打开您的项目并转到右侧的齿轮图标,那么"Edit Project"您可以为项目设置默认分支。
在 Gitlab CE 9.0 中,您可以从存储库 header 的“设置”选项卡更改默认分支。
在最新的 GitLab Community Edition 版本 9.2.2 中:
- 您必须单击位于选项卡最右侧的 'Settings' 选项卡 打开项目后的面板。
- 在 'Settings' 下,您将看到 'Default Branch' 部分下拉菜单 这将为您提供存储库的所有分支。 Select 所需的分支。
- 向下滚动点击绿色 'Save changes' 按钮 在 'Project Avatar'. 之后
请参考下图:
- 设置
- 一般
- 常规项目设置
要更改 GitLab 中的默认分支:
1. 设置 > 通用 > 通用项目设置 > 展开
2. 默认分支 > 更改项目默认分支
3. 保存更改
对于 gitlab v10+(截至 2018 年 9 月),这已移至设置-> 存储库-> 默认分支
如@Luke 所述,这在 4/1/2021
仍然有效对于 GitLab 11.5.0-ee,转到
https://gitlab.com/<username>/<project name>/settings/repository
.
你应该看到:
Default Branch
Select 您要设置为该项目默认的分支。除非您指定一个不同的分支,否则所有合并请求和提交都将自动针对此分支进行。
单击展开,select 一个分支,然后单击保存更改。
在Gitlab v11.4.4-ee版本中,您可以:
- 设置
- 存储库
- 默认分支
设置 > 存储库 > 默认分支
在 GitLab Enterprise Edition 12.2.0-pre 中,您必须使用以下内容:
Setting
→ Repository
→ Default Branch
(展开它)并在此处更改默认分支
另见 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 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 frommaster
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.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.