Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git basics
  6. Syncing repositories
  7. Resolving merge conflicts
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Resolving merge conflicts

Conflicts occur when changes made in the local repository and the remote repository cannot be automatically reconciled by Git. When conflicts arise, Git will prompt you to resolve them by choosing which changes to keep or by manually editing the conflicting files.

You may come across a conflict that needs resolving before you can properly complete a merge. For example, if two or more members make changes on the same part of a file in two different branches (i.e., remote and local branches), Git cannot merge them automatically.

Git adds conflict-resolution markers to the conflicting file when this happens. The markers help you figure out which sections of the file need to be resolved manually.

Diagram of a merging change.
Example of a conflict occurrence.

In our example above, everything above ===== is your local content, and everything below comes from the remote branch.

You must resolve the conflicting parts as shown below before you can proceed with creating a merge commit.

Diagram of a merging change.
Revise the change set to eliminate the conflict.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life