Merge Conflicts

๐Ÿ“˜ Git & GitHub ๐Ÿ“— Chapter 13 of 40 ๐Ÿ“‚ Phase 4: Branches ๐Ÿ—“๏ธ 2026 Edition
๐Ÿ“Œ Covered in this chapter: Conflict Markers ยท Resolving Conflicts ยท git merge --abort

Resolve merge conflicts confidently by reading conflict markers and choosing (or combining) the correct changes.

1Merge Conflicts โ€” What You'll Learn

Resolve merge conflicts confidently by reading conflict markers and choosing (or combining) the correct changes.

Here's everything this chapter covers, in the order you'll learn it:

  • Why merge conflicts occur
  • Reading conflict markers in a file
  • Choosing the current branch's change
  • Choosing the incoming branch's change
  • Combining both changes manually
  • Marking a conflict as resolved
  • Completing the merge after resolving
  • Aborting a merge entirely
  • Preventing conflicts through smaller, frequent merges
  • Communicating with teammates about conflicting work
2Working Example
๐Ÿ’ป Example: Merge Conflicts
Text
<<<<<<< HEAD
Current branch code
=======
Incoming branch code
>>>>>>> feature-branch
๐Ÿ’ป Continued Example
Bash
git status
git add resolved-file.js
git commit
# Or, to cancel entirely:
git merge --abort
3Best Practices & Common Pitfalls
๐Ÿ’ก Key things to remember:
  • Conflict markers (<<<<<<<, =======, >>>>>>>) must be manually deleted after you decide what the final code should look like โ€” Git won't remove them for you.
  • git merge --abort safely cancels a messy merge and returns you to exactly where you were before it started.
โ“ Frequently Asked Questions (FAQ)

Q What's the most important thing to understand about merge conflicts?

Focus on: Conflict Markers ยท Resolving Conflicts ยท git merge --abort. These are the core building blocks this chapter's examples are built around, and they show up repeatedly in later chapters of this course.

Q Is merge conflicts something I'll use often in real projects?

Yes โ€” every concept in this chapter reflects a real, everyday part of professional Git and GitHub workflows, not just a theoretical exercise.

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy ยท Last updated August 2026