Merge Conflict
After pulling, Git stopped with a conflict. Which file do I open, and which section do I change?
When to use it
- Find the conflicted files and open them$ git statusboth modified: index.htmlOpen this file first, then search the conflict markers
- Keep the correct result after understanding both sidesEach side changed a part; merge into one version when both are needed<h1>Xiaoli's photography homepage</h1><p>City collection</p>
- Stage and commit only after markers are gone$ git add index.html$ git commit[main 3f9c2ab] Merge branch feature/new-navCommit only after the markers are gone
- Rerun the project to confirm both sides still workConflict resolved→Open the page→Heading correct ✓Rerun to confirm both sides' changes are still there
When NOT to use it
- Commit with any conflict marker left in the file<<<<<<< HEADMarkers left in the file break page parsing
<h1>Xiaoli's homepage</h1> - Delete a whole section without reading the other sideThe heading bug the other side just fixed gets deleted tooDeleting a whole section without reading the other side may drop needed fixes
- Treat git merge --abort as resolution: it only returns to the pre-merge state, leaving changes unmergedgit merge --abort→All changes remain unmerged
- Mix unrelated edits into the conflict resolutionChanged styles and copy while resolving the heading conflictThis commit mixes unrelated changes, hard to revert and review
The markers surround the two headings; the navigation outside them still needs to be retained.
Xiaoli’s photography homepage
Contact Xiaoli
Markers are gone. The page shows the final heading, the feature branch navigation, and main’s existing contact content.