Resolving a merge request locally with a protected branch

Viewed 3280

I am using Gitlab, and I have a conflict on my merge request that I cannot resolve with the online tool. I checkout the target branch and resolve the conflict, then ... Then what ?

  • The branch is protected, so no one is allowed to push on it.
  • No option available on Gitlab to do something like this.

What is supposed to be the correct "way" of doing in those cases ? Are we supposed to create another branch to solve the conflict, then another merge request ? Or is there a commmand line / an alternative I failed to see when searching for a solution, like "push the result of the solving conflict which is not a commit per se" ?

2 Answers

Are we supposed to create another branch to solve the conflict, then another merge request ?

Yes, I'd suggest doing this.

1) Create a new branch off the destination branch
2) Merge your feature branch in it
3) Solve conflicts, add them, and commit the merge
4) Push that new branch to remote
5) Create a new PR from the new branch to the destination one

The branch is protected, so no one is allowed to push on it.

I assume you mean target branch is protected and my answer is based on that.

To avoid merge conflicts in Gitlab I usually choose one of the 2 options:

  1. Rebase development branch on target branch, solve conflicts during rebase and push force updated branch:
git checkout <development branch>
git rebase <target branch>
# optionally interactive rebase, if I have many commits I like to squash them to avoid solving the same conflicts over and over again
# git rebase -i <target branch>
git push -f
  1. Merge target branch to your development branch locally and solve the conflicts, push it to Gitlab, then you should not have any merge conflicts on your MR.
Related