如何防止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.
- 转到您的
project
- 导航到项目
settings
(注意:这不是右上角可用的配置文件设置) - 转到
General
标签. - 导航到
Merge Request Settings
部分 - 选择
Fast-Forward Merge
.
- 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屋!