DataSpell 2022.3 Help

Resolve conflicts

When you work in a team, you may come across a situation when somebody commits changes to a file you are currently working on. If these changes do not overlap (that is, changes were made to different lines of code), the conflicting files are merged automatically. However, if the same lines were affected, your version control system cannot randomly pick one side over the other, and asks you to resolve the conflict.

Conflicts may also arise when merging, rebasing or cherry-picking branches.

Conflicts in Git

In Git, conflicts arise when a file you have committed locally has changes to the same lines of code as the latest upstream version and when you attempt to perform one of the following operations: pull, merge, rebase, cherry-pick, unstash, or apply patch.

If there are conflicts, these operations will fail, and you will be prompted to accept the upstream version, prefer your version, or merge the changes manually:

DataSpell: Git conflicts dialog

The Conflicts dialog is triggered automatically when a conflict is detected on the Version Control level.

If you click Close in this dialog, or call a Git operation that leads to a merge conflict from command line, a Merge Conflicts node will appear in the Local Changes view with a link to resolve them:

The Merge Conflicts node in the Local Changes view

DataSpell provides a tool for resolving conflicts locally. This tool consists of three panes:

  • The left page shows the read-only local copy

  • The right pane shows the read-only version checked in to the repository

  • The central pane shows a fully-functional editor where the results of merging and conflict resolving are displayed. Initially, the contents of this pane is the same as the base revision of the file, that is, the revision from which both conflicting versions are derived.

color coding in the conflict resolution tool

Resolve conflicts

  1. Click Merge in the Conflicts dialog, the Resolve link in the Local Changes view, or select the conflicting file in the editor and choose Git | Resolve Conflicts from the main menu.

  2. To automatically merge all non-conflicting changes, click the Apply Non-Conflicting Changes button (Apply All Non-Conflicting Changes) on the toolbar. You can also use the the Apply Non-Conflicting Changes from the Left button (Apply Non-Conflicting Changes from the Left Side) and the Apply Non-Conflicting Changes from the Right button (Apply Non-Conflicting Changes from the Right Side) to merge non-conflicting changes from the left/right parts of the dialog respectively.

  3. To resolve a conflict, you need to select which action to apply (accept the Accept button or ignore the Ignore button) to the left (local) and the right (repository) version, and check the resulting code in the central pane:

    Resolve conflicts

    You can also right-click a highlighted conflict in the central pane and use the commands from the context menu. The Resolve using Left and Resolve using Right commands provide a shortcut to accepting changes from one side and ignoring them from the other side respectively:

    The context menu of a conflicting change

    For simple conflicts (for example, if the beginning and the end of the same line have been modified in different file revisions), the Resolve simple conflicts the Resolve simple conflicts button button that allows merging the changes in one click becomes available.

    the Resolve Simple Conflicts button

    Such conflicts are not resolved with the Apply All Non-Conflicting Changes action since you must make sure that they are resolved properly.

  4. Review merge results in the central pane and click Apply.

Productivity tips

Apply non-conflicting changes automatically

You can configure DataSpell to always apply non-conflicting changes automatically instead of telling it to do so from the Merge dialog. To do this, select the Automatically apply non-conflicting changes option on the Tools | Diff Merge page of the IDE settings Ctrl+Alt+S.

Last modified: 26 September 2022