Frequently Asked Question
How do I resolve a merge conflict?
A conflict arises when two branches have made incompatible changes to the same lines,
or when one has deleted a file the other has modified. Git stops the merge, marks the
conflicted regions in each affected file with <<<<<<<, =======, and >>>>>>>
markers showing the two competing versions, and records the unresolved state in the
index. git status lists the conflicted files; git diff shows the conflicts. Until
you finish, you are mid-merge, you cannot make new commits.
Open each conflicted file, decide what the final text should be (usually some
combination of both sides), delete the conflict markers, save, then git add the
file. When every conflict is resolved, git commit finishes the merge with a merge
commit. Tools like git mergetool will launch a graphical three-way merge editor
(VS Code, meld, kdiff3) which is much less error-prone than editing markers by hand.
If you get into a hopeless mess, git merge --abort undoes the merge and returns you
to where you started.