Skip to content

Merge Conflict

In one line

A merge conflict occurs when two branches change the same lines of the same file and Git cannot decide which version to keep.

In simple words

When merging or rebasing, Git tries to combine changes automatically. If both branches modified the same lines, Git cannot know which version is correct — it reports a merge conflict and pauses, asking you to resolve it manually.

Conflicted files contain markers: <<<<<<< marks the start of the current branch's version, ======= separates the two versions, and >>>>>>> marks the end of the incoming branch's version. You edit the file to keep the correct version, remove the markers, git add the file, and commit.

Conflicts are more likely when branches diverge significantly or multiple people edit the same file. To minimize conflicts: pull frequently, keep branches short-lived, communicate with your team, and consider smaller, more focused files.

Example

text
<<<<<<< HEAD
const port = 3000;
=======
const port = 8080;
>>>>>>> feature

# Resolve: choose one, remove markers
const port = 8080;

Markers show both versions. Edit to keep the correct one, remove markers, add, commit.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary