How to prevent Gitlab from creating extra merge commit on branch merge

后端 未结 5 2042
庸人自扰
庸人自扰 2021-02-13 02:16

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

  1. I created a topic_branch from master.
  2. Made a bunch of commit
5条回答
  •  温柔的废话
    2021-02-13 03:07

    1. checkout master
    2. merge topic_branch into master
    3. commit / push master In this case, there would be only 1 commit on master.

    That is not true. You will have all the commits from topic_branch and a Merge branch 'topic_branch'commit in your master, except the case that no commits were added to your master branch since you branched off topic_branch. In this case, the default behaviour of git merge is to perform a fast forward merge. A fast forward merge merges your topic_branches changes to master without a merge commit (see here for further documentation).

    However, when you create a merge request in GitLab, as the name says, you are requesting to merge your topic_branch into your code base. Per default, GitLab will always create a merge request, even if a fast forward merge is possible, to preserve the fact that the commits were developed on another branch in your history.

    Now the good news: you can configure GitLab to perform fast-forward merges instead of creating merge commits: see here. It seems, however, that this is only possible in GitLab Enterprise Edition.

提交回复
热议问题