如何将ID ID从分支名称添加到合并请求说明模板?
默认情况下,GitLab 将分支名称中的问题 ID 添加到合并请求描述中,请参阅 合并请求以关闭问题:
合并请求以关闭问题
要创建合并请求以在合并时关闭问题,您可以:
在 MR 描述中添加注释。
在问题中,选择创建合并请求。然后,您可以:
- 一次性创建新分支和草稿合并请求。默认情况下,分支名为
issuenumber-title
,但您可以选择任何名称,GitLab 会验证它是否尚未在使用中。合并请求继承问题的里程碑和标签,并设置为合并时自动关闭问题。- 仅创建一个新分支,其名称以问题编号开头。
但我想使用自定义合并请求描述模板,请参阅 创建合并请求模板:
创建合并请求模板
与问题模板类似,在存储库的
.gitlab/merge_request_templates/
目录中创建一个新的 Markdown (.md
) 文件。提交并推送到您的默认分支。
研究
- GitLab Flavored Markdown 不包含任何标记获取分支名称中的问题 ID。
- about.GitLab.com 的 Markdown 样式指南 不包含该问题的任何标记分支名称中的 ID。
- GitLab 快速操作 不包含针对问题 ID 的任何操作分支机构名称。
问题
如何将分支名称中的问题 ID 添加到合并请求描述模板中?
By default GitLab adds issue ID from branch name to the merge request description, see Merge requests to close issues:
Merge requests to close issues
To create a merge request to close an issue when it’s merged, you can either:
Add a note in the MR description.
In the issue, select Create a merge request. Then, you can either:
- Create a new branch and a draft merge request in one action. The branch is named
issuenumber-title
by default, but you can choose any name, and GitLab verifies that it’s not already in use. The merge request inherits the milestone and labels of the issue, and is set to automatically close the issue when it is merged.- Create a new branch only, with its name starting with the issue number.
But I want to use a custom merge request description template, see Create a merge request template:
Create a merge request template
Similarly to issue templates, create a new Markdown (
.md
) file inside the.gitlab/merge_request_templates/
directory in your repository. Commit and push to your default branch.
Research
- GitLab Flavored Markdown doesn't contain any markup for the issue ID from the branch name.
- Markdown Style Guide for about.GitLab.com doesn't contain any markup for the issue ID from the branch name.
- GitLab quick actions doesn't contain any action for the issue ID from the branch name.
Question
How to add issue ID from branch name to the merge request description template?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在寻找类似的问题,我发现 Push Options 可以解决此问题:
https://docs.gitlab.com/ee/user/project/push_options。 html
例如:
确实这必须由开发者在客户端设置,但是有了 git hooks 和 shell 脚本,内容可以是任何东西!
I'm looking for a similar problem, i see that Push Options can be a solution for this:
https://docs.gitlab.com/ee/user/project/push_options.html
for example:
It is true that this must be set up by the developer on the client side, but with git hooks and shell scripts, the content can be anything!