GitLab merge behavior - keep file from branch

僤鯓⒐⒋嵵緔 提交于 2021-02-08 07:58:29

问题


Is it possible to default to one branche's version of a file when doing merge requests in GitLab Web Interface?

I'm trying to set up the GitLab Web Interface, so that you can use the graphical interface to do merge requests. In these merge requests, certain files on the target branch must not be subject to any changes.

Most often, I'm working on web projects with a config.php, and here we can see how it's possible to not overwrite the config in branch 'prod' with anything (ie from 'dev')

.gitattributes & individual merge strategy for a file

I tried to apply this to our server by doing

    # 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

I expected the "OneMoreLine" to be missing in production, but GitLab seems to be unaffected by the .gitattributes and config.

Can we somehow configure GitLab to achieve this? Perhaps with a non-global or other user's config?

来源:https://stackoverflow.com/questions/42720116/gitlab-merge-behavior-keep-file-from-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!