如何防止 Gitlab 在分支合并上创建额外的合并提交 [英] How to prevent Gitlab from creating extra merge commit on branch merge
问题描述
我在我的项目中使用 GitLab.我正在探索合并请求功能.
I use GitLab in my project. I'm exploring Merge Requests feature.
- 我从
master
创建了一个topic_branch
. - 在
topic_branch
上做了一堆提交. - 将
topic_branch
推送到远程. - 在
master
上创建了一个合并请求,以从topic_branch
中提取更改. - 在 Gitlab 中接受合并时,
master
提取了所有提交并创建了一个合并提交,这对于看到代码重复非常可怕.
- I created a
topic_branch
frommaster
. - Made a bunch of commits on
topic_branch
. - Pushed
topic_branch
to remote. - Created a merge request on
master
to pull changes fromtopic_branch
. - On accept merge in Gitlab,
master
pulled all the commits and also created a merge commit which is horrible to see duplication of code.
我应该在分支上创建一个提交的壁球,然后创建合并请求.但是 master
仍然会有两个新的提交,一个来自分支,另一个是合并提交.我假设,如果我从命令行执行此操作,即
I should have created a squash of commits on branch and then created merge request. But still master
would have two new commits, one from the branch and another one would be merge commit. I'm assuming, if I do this from command line i.e,
- 结帐
master
- 将
topic_branch
合并到master
- 提交/推送
master
在这种情况下,master
上只有 1 次提交.
- checkout
master
- merge
topic_branch
intomaster
- commit / push
master
In this case, there would be only 1 commit onmaster
.
如何从 GitLab 实现这一目标?
How to achieve this from GitLab ?
推荐答案
TL;DR
您的项目 >设置 >一般 >合并请求设置 >快进合并.
TL;DR
Your Project > Settings > General > Merge Request Settings > Fast-Forward Merge.
就个人而言,我也更喜欢在每次合并时执行 squash commits
.
Personally, I also prefer to do squash commits
on every merge.
我认为 GitLab 现在支持这一点.
I think GitLab supports this now.
- 转到您的
项目
- 导航到项目
settings
(注意:这不是右上角可用的配置文件设置) - 转到
常规
标签. - 导航到
合并请求设置
部分 - 选择
快进合并
.
- Go to your
project
- Navigate to project
settings
(Note: This is NOT the profile settings available on the top right) - Go to
General
tab. - Navigate to
Merge Request Settings
section - Choose
Fast-Forward Merge
.
这篇关于如何防止 Gitlab 在分支合并上创建额外的合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!