Skip to main content
AllDevToolsHub
Back to error codes
ERROR CONFLICT

Git Merge Conflict

Git Error

Two branches have made conflicting changes to the same part of a file.

Root Cause

Both branches modified the same lines in a file, and Git cannot automatically determine which version to keep.

How to Fix

Open the conflicted files, resolve the conflict markers (<<<<<<<, =======, >>>>>>>), stage the resolved files, and complete the merge with git commit.

Quick Summary

Git merge conflicts occur when two branches modify the same lines. Resolve by editing the conflict markers in the file, staging the resolved files, and completing the merge.

Key Takeaways

Key Takeaways

  • Conflict markers: <<<<<<< HEAD (your changes), ======= (separator), >>>>>>> branch (incoming changes)
  • Resolve by editing the file to keep the correct version
  • Stage resolved files: git add <file>
  • Complete the merge: git commit (or git rebase --continue for rebases)
Use Cases

When to use it

  • Two developers edited the same function
  • Merging a long-lived feature branch
  • Rebasing onto an updated main branch
Watch out

Common Mistakes

  • Accepting all incoming or all current changes without reviewing, always understand what each side changed
  • Not running tests after resolving conflicts
FAQ

CONFLICT Git Merge Conflict, Frequently Asked

How do I abort a merge with conflicts?

git merge --abort, this restores the repository to the state before the merge started.

Still having issues?

Check your network logs or use our developer tools to inspect headers, decode tokens, or validate your requests.