1

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?

Community
  • 1
  • 1
NoMad
  • 702
  • 2
  • 11
  • 27
  • GitLab is not Git, so this *might* not be the problem; but GitLab *uses* Git, so it probably is: http://stackoverflow.com/a/41825703/1256452 – torek Mar 10 '17 at 14:24
  • Seems like I was right with the non-global config. I think I can add the git configuration (merge.ours.name/driver) in gitlab.rb. It has a section for its own (omnibus) git config... – NoMad Mar 10 '17 at 15:00

0 Answers0