JetBrains Rider
 
2024.3
Get JetBrains Rider

Resolve Git conflicts

Last modified: 08 October 2024

When you work in a team, you may come across a situation when somebody pushes 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, Git cannot randomly pick one side over the other, and asks you to resolve the conflict.

In Git, conflicts may arise when you attempt to perform one of the following operations: pull, merge, rebase, cherry-pick, unstash changes or apply a 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:

Merge Conflicts dialog

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

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

The Merge Conflicts node in the Local Changes view

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

  • The left pane shows the read-only local copy

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

  • The central pane is a fully-functional editor where the results of resolving conflicts are displayed. Initially, the contents of this pane are 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
  1. Modified line

  2. Deleted lines

  3. Newly added lines

  4. Conflicting lines