git 如何在 Gitlab 中更改合并的默认目标分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38913163/
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
How to change the default target branch for merges in Gitlab
提问by Tobias Mantsch
we are using Gitlab 8.10.1 with many groups and projects. Many of the projects happen to be forks of other projects. Our problem is that whenever somebody opens a merge request for a project the default target branch is NOT the default branch of the project but from one very specific other project. Is there a way to override this setting somehow? Just to make it clear, I know how to set the default branch of a project and those settings appear to be correct, however gitlab doesn't seem to use them when creating merge requests. This issue is very annoying and has led to weird situations when people didn't pay attention and made merge requests with a completely different "master" as target.
我们在许多组和项目中使用 Gitlab 8.10.1。许多项目恰好是其他项目的分支。我们的问题是,每当有人打开项目的合并请求时,默认目标分支不是项目的默认分支,而是来自一个非常具体的其他项目。有没有办法以某种方式覆盖此设置?为了清楚起见,我知道如何设置项目的默认分支并且这些设置似乎是正确的,但是 gitlab 在创建合并请求时似乎没有使用它们。这个问题非常烦人,当人们不注意并以完全不同的“master”作为目标提出合并请求时,会导致奇怪的情况。
采纳答案by Tobias Mantsch
We found the source for this behavior, it is due to the relationship between the projects as one project was forked in gitlab from the other. When removing the relation between the source and the fork, the default branch for merges is the default branch of the project itself. Right now this is our solution for this situation, as we can live with the implications of the removal of the source<->fork relation.
我们找到了这种行为的根源,这是由于项目之间的关系,因为一个项目在 gitlab 中是从另一个项目分叉出来的。删除源和分支之间的关系时,合并的默认分支是项目本身的默认分支。现在这是我们针对这种情况的解决方案,因为我们可以接受删除源<->分叉关系的影响。
回答by David P
The default MR target depends on whether or not the repository is a GitLab fork.
默认 MR 目标取决于存储库是否为GitLab fork。
Forks
货叉
If the repository is a GitLab fork, then the default MR target will be the default branch of the upstream repository. This relationship can be removed via the "Remove fork relationship" option on the Project settings page, after which the default MR target will be determined as normal for a non-fork repository (described below).
如果存储库是GitLab fork,则默认 MR 目标将是上游存储库的默认分支。可以通过项目设置页面上的“删除分叉关系”选项删除此关系,之后默认 MR 目标将被确定为非分叉存储库的正常目标(如下所述)。
At time of writing, it is not possible to override the default MR target without removing the fork relationship, but that functionality has been requested in gitlab issue #14522.
在撰写本文时,不可能在不删除 fork 关系的情况下覆盖默认 MR 目标,但该功能已在 gitlab 问题#14522 中请求。
Non-Forks
非分叉
If the repository has no fork relationship, then the Default Branch setting on the Project settings page sets both (1) the default MR target, and (2) the HEAD reference of the repo on the GitLab server (which determines the branch that's checked out when the repo is cloned). Note that, due to a bug/quirk in git, problems can occurif a branch that was once the Default Branch is later deleted from GitLab.
如果存储库没有分叉关系,则项目设置页面上的默认分支设置会同时设置 (1) 默认 MR 目标和 (2) GitLab 服务器上的存储库的 HEAD 引用(它确定签出的分支)当 repo 被克隆时)。需要注意的是,由于错误/怪癖在Git中,可能会出现问题,如果一个分支,它曾经是默认分支稍后从GitLab删除。
At time of writing, it is not possible to change the default MR target independently of the Default Branch, but this functionality has been requested in gitlab issue #17909.
在撰写本文时,无法独立于默认分支更改默认 MR 目标,但此功能已在 gitlab 问题#17909 中请求。
回答by sicheng zuo
you need master。 Then Project setting---Default Branch ---save change
你需要master。 然后项目设置---默认分支---保存更改
Enjoy!
享受!
回答by Noah Martin
As of version 11.5.3 the settings changed a bit. From docs.gitlab.com:
从版本 11.5.3 开始,设置发生了一些变化。来自docs.gitlab.com:
When you create a new project, GitLab sets master as the default branch for your project. You can choose another branch to be your project's default under your project's Settings > Repository.
创建新项目时,GitLab 将 master 设置为项目的默认分支。您可以在项目的 Settings > Repository 下选择另一个分支作为项目的默认分支。