Course contentsShow
← Git & GitHub
Lesson 65 of 964. Collaborative WorkflowsFree lesson

Resolving Merge Conflicts in Collaborative Workflows

Gain the ability to identify and resolve conflicting code changes when multiple contributors modify the same files simultaneously.

In this lesson, you will learn how to orchestrate the resolution of merge conflicts when your team’s independent contributions overlap in the same file.

When working in a collaborative environment, it is common for two developers to modify the same line of code in different feature branches. When you attempt to merge these branches or pull updates from a remote repository, Git will pause and report a "merge conflict" because it cannot automatically determine which version of the code is intended to persist.

The Anatomy of the Conflict

When a conflict occurs, Git marks the problematic section in your source file with specific syntax:

<<<<<<< HEAD
print("Hello from Feature A")
=======
print("Hello from Feature B")
>>>>>>> branch-name

The area between <<<<<<< and ======= represents your current local changes, while the area between ======= and >>>>>>> shows the incoming changes from the branch you are attempting to merge.

Resolving the Conflict

To resolve this in a collaborative workflow, follow these systematic steps:

  1. Identify the conflict: After a failed git merge or git pull, run git status to see which files are "both modified."
  2. Edit the file: Open the conflicted file and manually delete the conflict markers (<<<<<<<, =======, >>>>>>>). Edit the code so it reflects the desired, integrated state. You might need to coordinate with your teammate via a Pull Request discussion or a chat to decide whose logic should take priority, or how to combine both features.
  3. Stage the resolution: Once the file is clean and contains only the code you want to keep, run git add <filename> to signal to Git that the conflict has been resolved.
  4. Finalize the commit: Run git commit to finalize the merge process. If you were in the middle of a git pull, finishing the commit essentially reconciles the diverged history.

By communicating clearly with your team and handling these markers deliberately, you turn a potential blocker into a moment of intentional code integration.

Key Takeaway: Resolving conflicts is a collaborative exercise; use conflict markers to identify the gap, manually integrate the logic, and stage your resolution to reconcile divergent team contributions.