如何防止 Gitlab 在分支合并上创建额外的合并提交 [英] How to prevent Gitlab from creating extra merge commit on branch merge

查看:13
本文介绍了如何防止 Gitlab 在分支合并上创建额外的合并提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用 GitLab.我正在探索合并请求功能.

I use GitLab in my project. I'm exploring Merge Requests feature.

  1. 我从 master 创建了一个 topic_branch.
  2. topic_branch 上做了一堆提交.
  3. topic_branch 推送到远程.
  4. master 上创建了一个合并请求,以从 topic_branch 中提取更改.
  5. 在 Gitlab 中接受合并时,master 提取了所有提交并创建了一个合并提交,这对于看到代码重复非常可怕.
  1. I created a topic_branch from master.
  2. Made a bunch of commits on topic_branch.
  3. Pushed topic_branch to remote.
  4. Created a merge request on master to pull changes from topic_branch.
  5. 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,

  1. 结帐master
  2. topic_branch 合并到 master
  3. 提交/推送 master在这种情况下,master 上只有 1 次提交.
  1. checkout master
  2. merge topic_branch into master
  3. commit / push master In this case, there would be only 1 commit on master.

如何从 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.

  1. 转到您的项目
  2. 导航到项目settings(注意:这不是右上角可用的配置文件设置)
  3. 转到常规标签.
  4. 导航到合并请求设置部分
  5. 选择快进合并.
  1. Go to your project
  2. Navigate to project settings (Note: This is NOT the profile settings available on the top right)
  3. Go to General tab.
  4. Navigate to Merge Request Settings section
  5. Choose Fast-Forward Merge.

这篇关于如何防止 Gitlab 在分支合并上创建额外的合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆