[go: up one dir, main page]

Skip to content

Manually resolve conflicts in merge commit on the target branch

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

GitLab resolves merge conflicts by merging the target branch into the source branch before then merging into the target branch. This is often surprising and confusing for users accustomed to the GitHub workflow.

The user expects the resolve of resolving conflicts to be a merge commit in the target branch that resolves the conflicts.

Further details

There are multiple ways to resolve merge conflicts using Git: (1) rebase, (2) resolve the conflicts in the source branch before merging into the target branch, and (3) resolving conflicts in the merge commit that merges the changes from the source branch into the target branch.

GitLab should support resolving conflicts in the merge commit that merges the changes from the source branch into the target branch directly in the GitLab interface. This could be called Resolve conflicts in merge commit

To illustrate the difference between these approaches by way of example, changes have been added to master that cause our new feature branch to have conflicts with master preventing it from being merged.

	  X feature
	 /
    A---B---C master

There are a couple of ways address this:

  1. rebase feature branch on master locally, then merge; or

              Y feature
             / \
        A---B---C---o master
  2. Resolve conflicts (this could also be done locally too) – merge changes from master branch into feature branch to resolve the conflicts, then merge feature branch into master branch; or

              X---Z feature
             /   / \
        A---B---C---o master
  3. Merge locally – locally merge changes from feature branch directly in to master and resolve the conflicts in the merge commit

              X---. feature
             /     \
        A---B---C---o master

GitLab's Resolve conflicts feature uses approach number two, which is merging the changes from the target branch back into the source branch, so that a clean merge can occur.

The downside of this is that it creates an additional merge commit.

Proposal

Add support for resolving conflicts using the GitLab interface in the merge commit on the target branch.

Links / references

Edited by 🤖 GitLab Bot 🤖