← Back to all fixes
Git

Merge conflict blocks PR merge

The Issue

GitHub shows "This branch has conflicts that must be resolved" and the merge button is disabled.

Root Cause

Same lines were changed in both the source branch and the target branch (e.g. main).

How to Fix
  1. Pull the latest target branch: `git fetch origin && git checkout main && git pull`
  2. Merge target into your branch: `git checkout my-feature && git merge main`
  3. Open conflicting files — look for `<<<<<<`, `=======`, `>>>>>>>` markers
  4. Edit the file to keep the correct code, remove the conflict markers
  5. Stage resolved files: `git add <file>` then `git commit`
  6. Push and the PR conflict should clear