A merge conflict happens when Git can't automatically combine two changes — usually because both branches edited the exact same lines differently. It's not an error to be afraid of; it's Git correctly refusing to guess.
git merge feature-login
# Auto-merging index.html
# CONFLICT (content): Merge conflict in index.html
# Automatic merge failed; fix conflicts and then commit the result.Git edits the conflicted file directly, marking both versions.
<h1>Welcome</h1>
<<<<<<< HEAD
<p>This is the main branch version.</p>
=======
<p>This is the feature-login branch version.</p>
>>>>>>> feature-login| Marker | Meaning |
|---|---|
| <<<<<<< HEAD | Start of the current branch's version |
| ======= | Divider between the two versions |
| >>>>>>> feature-login | End of the incoming branch's version, naming it |
Edit the file by hand — keep one version, keep the other, or write something combining both — and remove every marker line entirely.
<h1>Welcome</h1>
<p>This is the main branch version.</p>git add index.html
git commit
# Git pre-fills a merge commit message — usually fine to accept as-is# See every file still needing resolution
git status
# Both modified: index.html
# Both modified: style.cssIf a merge goes badly wrong partway through, it can be abandoned completely, returning to the state right before it started.
git merge --abortA faster way to resolve these in practice
Most code editors (VS Code among them) show conflict markers with clickable "Accept Current," "Accept Incoming," and "Accept Both" buttons — genuinely worth using instead of editing markers by hand once conflicts happen regularly.