Skip to main content

How to Resolve Merge Conflicts

Merge conflicts or code collisions sometimes occur as a normal part of the merge request workflow. However, they can be annoying for developers, especially when working on larger projects and in larger teams, where the chance of code collisions are increased. However, techniques exist to avoid encountering merge conflicts in the first place, and DataOps provides functionality for the online resolution of conflicts that do occur.

Avoiding Merge Conflicts

In order to reduce the chance of code conflicts affecting your merge requests, the following tips, techniques, and best practices are present and recommended in DataOps projects:

  • Structure code in multiple, smaller files rather than large ones.
  • Keep merge requests small and specific, minimizing code changes to a particular change.
  • Merge as soon as possible, with regular review/approval cycles to avoid delays.
  • Avoid non-standard code beautifiers that reformat whole files.
  • Rebase your branch regularly if work spans multiple days.
  • Ensure good communication within teams to better understand potential code overlaps.

Resolving Merge Conflicts in DataOps

When raising and reviewing merge requests in DataOps, developers and maintainers should see the following view - a safely-mergeable branch:

no-conflict-mr __shadow__

However, if there is a conflict in a file, usually caused by code changes that abut or overlap, the merge section should look like this:

merge-conflict-resolvable __shadow__

The DataOps IDE provides a mechanism to click through, review the conflicting content, and resolve the conflict to solve this merge conflict. Once the conflict has been resolved, the developer or maintainer can then by clicking the Resolve conflicts button:

resolve-conflicts __shadow__

note

There can be more than one merge conflict in a feature branch.

The correct change(s) can be selected from this view and committed back to the source branch. The merge will then be able to go ahead successfully.

However, some changes, particularly involving the renaming or deletion of files, will not be resolvable in the DataOps platform:

merge-conflict-unresolvable __shadow__

In these scenarios, the developer should clone the project locally and rebase against the target branch, resolving any conflicts by hand. The developer can then push the updated branch back to the merge request, which should then become mergeable.