MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Resolving Merge Conflicts Step-by-Step with Conflict Markers0%
Study Materials
Git & GitHub BasicsProgress 0%
1.1What is Version Control? (Local, Centralized vs Distributed VCS)1.2Why Git? History, Architecture & Core Benefits1.3The Three Trees: Working Directory, Staging Area & Git Repository1.4Installing Git and Initial Configuration (git config user.name / email)
4.1Git Branching Mechanics: Pointers, HEAD, and git branch4.2Switching Branches with git switch and git checkout -b4.3Merging Branches: Fast-Forward vs Three-Way Merges (git merge)4.4Resolving Merge Conflicts Step-by-Step with Conflict Markers
HomeTutorialsGit & GitHub BasicsResolving Merge Conflicts Step-by-Step with Conflict Markers
What is GitHub? Remote Hosting, Social Coding & Open Source

Resolving Merge Conflicts Step-by-Step with Conflict Markers

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

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.


1. What Causes a Merge Conflict?

A conflict occurs when:

  1. 1
    Developer A and Developer B branch from the same base commit.
  2. 2
    Developer A edits line 15 in server.js and commits it to main.
  3. 3
    Developer B edits line 15 in server.js in a conflicting way on feature-branch.
  4. 4
    When merging feature-branch into main, Git encounters conflicting modifications on line 15 and pauses the merge:
1Auto-merging src/server.js
2CONFLICT (content): Merge conflict in src/server.js
3Automatic merge failed; fix conflicts and then commit the result.

2. Anatomy of Git Conflict Markers

Git opens the conflicting file and marks the disputed lines with special ASCII delimiter markers:

1<<<<<<< HEAD
2const PORT = process.env.PORT || 8080; // Main branch setting
3=======
4const PORT = process.env.PORT || 5000; // Feature branch setting
5>>>>>>> feature-backend

Breakdown of the 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.

3. The 4-Step Method to Resolve Conflicts

Step 1: Identify Conflicted Files

Run git status to see which files have unresolved conflicts (listed under "Unmerged paths"):

1git status
2# Output: both modified: src/server.js

Step 2: Open and Edit the Conflicting File

Open src/server.js in your text editor (such as Visual Studio Code). Decide how the code should look:

  • Keep the HEAD version?
  • Keep the incoming version?
  • Combine ideas from both versions?

Critical Rule: You must completely delete all <<<<<<<, =======, and >>>>>>> lines from the file!

Cleaned resolution:

1// Clean resolved code
2const PORT = process.env.PORT || 8080;

Step 3: Stage the Resolved File

Staging the file informs Git that the conflict has been resolved:

1git add src/server.js

Step 4: Finalize the Merge Commit

1git commit

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!


4. Aborting a Merge (--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:

1git merge --abort

This safely rolls back the merge without losing any previous work.


Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
When does a Git merge conflict occur?
Question 2
In Git conflict markers, what does the content between <<<<<<< HEAD and ======= represent?
Question 3
What must a developer do with the markers (<<<<<<<, =======, >>>>>>>) when resolving a conflict?
Question 4
After manually editing a conflicted file and removing conflict markers, how do you signal to Git that the conflict is resolved?
Question 5
How can a developer abort an in-progress merge and return the repository to its pre-merge state?
Next Lesson

What is GitHub? Remote Hosting, Social Coding & Open Source

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Merging Branches: Fast-Forward vs Three-Way Merges (git merge)What is GitHub? Remote Hosting, Social Coding & Open Source

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Git & GitHub Basics with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext