- Resolve conflicts: interactive mode
- Resolve conflicts: inline editor
- Conflicts available for resolution
Merge conflicts occur when two branches have different changes that cannot be merged automatically.
Git can merge changes between branches in most cases, but occasionally Git requires your assistance to resolve the conflicts manually. Typically, this is necessary when people change the same parts of the same files.
GitLab prevents merge requests from being merged until all conflicts are resolved. Conflicts can be resolved locally, or in many cases in GitLab (see conflicts available for resolution for information on when this is available).
Clicking Resolve Conflicts displays a list of files with conflicts, with conflict sections highlighted:
After all conflicts have been marked as using ‘ours’ or ‘theirs’, the conflict
can be resolved. Resolving conflicts merges the target branch of the merge
request into the source branch, using the options
chosen. If the source branch is
feature and the target branch is
this is similar to performing
git checkout feature; git merge master locally.
Some merge conflicts are more complex, requiring you to manually modify a file to resolve them. Use the merge conflict resolution editor to resolve complex conflicts in the GitLab interface. Click Edit inline to open the editor. After you’re sure about your changes, click Commit to source branch.
GitLab allows resolving conflicts in a file where all of the below are true:
- The file is text, not binary
- The file is in a UTF-8 compatible encoding
- The file does not already contain conflict markers
- The file, with conflict markers added, is not over 200 KB in size
- The file exists under the same path in both branches
If any file in your merge request containing conflicts can’t meet all of these criteria, you can’t resolve the merge conflict in the UI.
Additionally, GitLab does not detect conflicts in renames away from a path. For example, this does not create a conflict:
- On branch
git mv file1 file2
- On branch
git mv file1 file3.
Instead, both files are present in the branch after the merge request is merged.