Merge conflicts are not software bugs or Git errors—they are a natural, protective feature of version control. When two developers change the exact same lines of the same file in different ways, Git refuses to guess which version is correct and safely halts, asking the developer to resolve the conflict.
A conflict occurs when:
server.js and commits it to main.server.js in a conflicting way on feature-branch.feature-branch into main, Git encounters conflicting modifications on line 15 and pauses the merge:Git opens the conflicting file and marks the disputed lines with special ASCII delimiter markers:
<<<<<<< HEAD : Marks the beginning of the conflicting section. Shows the version on the branch you are currently standing on (main).======= : The divider separating the two competing versions.>>>>>>> feature-backend : Marks the end of the conflict section and identifies the incoming branch that introduced the alternative.Run git status to see which files have unresolved conflicts (listed under "Unmerged paths"):
Open src/server.js in your text editor (such as Visual Studio Code). Decide how the code should look:
HEAD version?Critical Rule: You must completely delete all <<<<<<<, =======, and >>>>>>> lines from the file!
Cleaned resolution:
Staging the file informs Git that the conflict has been resolved:
Git will pre-populate a standard merge commit message: Merge branch 'feature-backend' into main. Save and exit the editor. Your merge is now complete!
--abort)If a merge is overwhelming or you started it by mistake, you can reset your working tree back to the state before the merge was attempted:
This safely rolls back the merge without losing any previous work.
<<<<<<< HEAD and ======= represent?<<<<<<<, =======, >>>>>>>) when resolving a conflict?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.