How to resolve conflict in merge request in gitlab?

Viewed 5304

I've got a merge request in gitlab:

Gitlab Screenshot

I have approved this request -- it looks good. I want to merge with master.

When I go to "Resolve Conflicts" I get the following:

Gitlab Merge Conflict Screenshot

Note, specifically, in the default commit message, it appears to be trying to merge 'master' into '156'. This is the opposite of what I want -- I want to merge these things into master.

Even if I solider forward and do the merge by picking one (and I'm not sure which is right because it's not clear what is 'mine' vs 'ours'... I'm returned back to the gitlab merge request page and told there are still conflicts - but now now button to do it in gitlab, only locally:

enter image description here

What am I doing incorrectly? Is there no method to merge via gitlab - do I have to do the merge locally and then push it?

1 Answers

Gitlab is right. What you're doing here by resolving conflicts, is merging master in 156.

First step before merging 156 in master is to have a clean tree state between the two branches, which means that all changes made on master should be reflected in 156 first. So yeah, you need to merge master in 156 before merging 156 in master.

Solution

This way of resolving conflicts forces you to have that annoying commit message. What I'd suggest here is rebasing 156 on master, which is something you cannot achieve on Gitlab GUI. Note that this would potentially override 156's history with master's, but that's what you need anyway.

# on branch 156
git fetch
git rebase origin/master
git push -f origin 156

Note : when rebasing 156 on master, ours would be master and theirs would be 156.

Related