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:
- Open the file, pick the correct code, and delete the
<<<<<<<,=======,>>>>>>>markers. git add <file>to mark it resolved.git committo finish the merge.
| Command | Helps with |
|---|---|
git status | Lists conflicted files |
git merge --abort | Bail out, back to pre-merge state |
git diff | See the conflicting regions |
Tip: Panicking mid-conflict? git merge --abort rewinds everything to before the merge. No harm done - then try again calmly.