Resolving Merge Conflicts

Merge Conflicts

Scenario: You and a teammate both edited line 10 of the same file on different branches. Git can't guess whose version wins - so it stops and asks you. This is a merge conflict, and it's normal, not a disaster.

Git marks the clash right in the file:

<<<<<<< HEAD
color = "blue";        // your version (current branch)
=======
color = "green";       // their version (branch being merged)
>>>>>>> feature-theme

To resolve:

  1. Open the file, pick the correct code, and delete the <<<<<<<, =======, >>>>>>> markers.
  2. git add <file> to mark it resolved.
  3. git commit to finish the merge.
CommandHelps with
git statusLists conflicted files
git merge --abortBail out, back to pre-merge state
git diffSee the conflicting regions
Tip: Panicking mid-conflict? git merge --abort rewinds everything to before the merge. No harm done - then try again calmly.