Merge Conflicts

Merge conflicts happen when different changes are made to the same parts of a file in different branches. Conflicts can happen when the changes you made locally contradict with changes made by others in the remote repository.

Remote Changes and Local Changes

  • Local Changes - These are changes you made locally that haven’t been pushed to your Git repository. They only exist locally for you.
  • Remote Changes - Remote is the term used for the location of your “main” repository. These changes have been made by others and are present in the remote repository. You encounter these changes when you fetch or pull updates from the remote repository.

Understanding a Merge Conflict

If a merge conflict occurs, Coalesce will pause the merging process and mark the file where the conflict exists. Understanding conflict markers is crucial to resolving conflicts.

  • Conflict Start Marker (<<<<<<<): This marker indicates the beginning of the conflicting area and is followed by your local changes.
  • Base Marker (=======): This marker separates your changes from the changes in the remote branch.
  • Conflict End Marker (>>>>>>>): This marker indicates the end of the conflicting area and is followed by the incoming changes from the remote branch.
Merge conflict markers example

Merge conflict markers example

<<<<<<< refs/heads/understanding_commits
defaultStorageMapping: null
defaultStorageMapping: WORK
>>>>>>> 81e4b8073446832faa2cdcfcc1bd9d54051b5108
fileVersion: 3

In this example, your local changes are defaultStorageMapping: null and you want to merge into the remote. But there is a conflict because remote has defaultStorageMapping: WORK.

To fix this error, you would remove all the other lines except for your changes. Watch out for empty lines.

Fixed merge conflict

Fixed merge conflict


Searching for Merge Conflicts

You can use your operating system's search functionality within the Merge Conflict Window by clicking CTRL + F or Command + F once your cursor is in the text box.

Large Merge Conflicts

There are times that conflicts are too complex to resolve within Coalesce and require going through the git provider's platform to resolve before merging the branches/commits. Our system will make you aware if this is the case and warn you accordingly. If you have a use case where you're running into this situation often, please reach out to our Support team.

General Steps to Resolve Merge Conflicts

  1. Identify the Conflicted Files: Coalesce will return all the files with conflicts.
  2. Review the Markers: Use the conflict markers to understand the differences between your local changes and the remote changes. Look at the code between the start and base markers to see your changes, and between the base and end markers to see the remote changes.
  3. Decide on the Changes to Keep: You need to decide whether to keep your local changes, accept the remote changes, or combine both. Ask your team to make sure you aren’t removing important work.
  4. Edit the File: Remove the conflict markers and make the necessary edits to the file to incorporate the chosen changes. Ensure that the code's functionality and syntax are correct.
  5. Complete the Merge: Continue with the merging process. Once all conflicts are resolved and the merge is successful, push your changes to the remote repository to share them with others.