GitLab 合并行为 - 将文件保留在分支中

问题描述 投票:0回答:1

在 GitLab Web 界面中执行合并请求时是否可以默认使用一个分支的文件版本?

我正在尝试设置 GitLab Web 界面,以便您可以使用图形界面来执行合并请求。在这些合并请求中,目标分支上的某些文件不得进行任何更改。

大多数情况下,我正在使用 config.php 处理 Web 项目,在这里我们可以看到如何不使用任何内容(即来自“dev”)覆盖分支“prod”中的配置

.gitattributes 和文件的单独合并策略

我尝试通过以下方式将其应用到我们的服务器

    # In my local repo
    git checkout production
    echo "config.php merge=ours" >> .gitattributes
    git add -A && git commit -am 'Add gitattributes'
    git push origin production

    git checkout -b dev
    rm .gitattributes
    echo "OneMoreLine" >> config.php
    git add -A && git commit -am 'Delete gitattributes, alter config'
    git push origin dev

    # SSH on the GitLab Server
    sudo git configure --global merge.ours.name "Keep OUR version"
    sudo git configure --global merge.ours.driver true

    # GitLab Web Interface /group/repo/tree/dev
    Create MR
    From dev into production

我预计

production
中会缺少“OneMoreLine”,但 GitLab 似乎不受 .gitattributes 和配置的影响。

我们可以通过某种方式配置 GitLab 来实现这一目标吗?也许使用非全局或其他用户的配置?

git gitlab git-merge merge-conflict-resolution
1个回答
0
投票

您可以根据

GitLab文档
/etc/gitlab/gitlab.rb中设置自定义合并驱动程序。

gitaly['configuration'] = {
  # ...
  git: {
    # ...
    config: [
      # ...
      { key: "merge.ours.name", value: "Keep OUR version" },
      { key: "merge.ours.driver", value: "true" },
    ],
  },
}
© www.soinside.com 2019 - 2024. All rights reserved.