Fix Git that says merge conflict
We'll check git status, find conflict markers, resolve or abort the merge, and confirm the repository is clean.
What you'll need
- Git installed and a repository with a merge in progress
- Text editor to edit conflicted files
Step-by-step diagnostic
Quick triage — pick your path
Quick triage — pick your path
Choose the option that matches what you see. You can jump straight to that section.
Show full guide
Steps
Goal: Check git status, find conflict markers, resolve or abort the merge, and confirm the repository is clean.
- Run
git status. Conflicted files appear under “Unmerged paths” or “both modified.” - Good: You see the list of conflicted files. Proceed to Abort or resolve.
- Bad: No merge in progress—you may have already resolved or never started a merge.
Abort or resolve
Goal: Abort the merge to cancel, or resolve the conflicts by editing files.
- If you want to cancel the merge, run
git merge --abort. When you abort then the working tree returns to before the merge. Confirm you should see “Merge aborted.” - If you want to resolve, proceed to Check conflict markers.
Check conflict markers
Goal: Understand and remove conflict markers in each conflicted file.
- Open each conflicted file in your editor. Look for conflict markers:
<<<<<<< HEAD,=======,>>>>>>> branch-name. - The text between
<<<<<<<and=======is your version; between=======and>>>>>>>is the incoming version. - Edit the file to keep the version you want or combine both. Remove all markers. Save the file.
- Run
git add path/to/filefor each resolved file. Confirm you should see all resolved files under “Changes to be committed,” with no “Unmerged paths.”
Complete the merge
Goal: Commit the merge and verify the working tree is clean.
- Run
git commit. Git opens your editor with a default merge commit message. Save and close. - Confirm you should see “Merge made by the ‘recursive’ strategy” or similar.
- Run
git status. Confirm you should see “nothing to commit, working tree clean.”
When to get help
If you have many conflicts across many files, or the conflict is in binary files, consider asking a teammate or using git mergetool. For complex history, a maintainer may need to help. Capture the output of git status and the branch names.
Verification
git statusshows “nothing to commit, working tree clean.”- No conflicted files remain under “Unmerged paths.”
- The merge commit is in the history (or the merge was aborted and you are back to the pre-merge state).
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Check status Run git status to see which files have conflicts.
- Abort or resolve Run git merge --abort to cancel, or open files and resolve markers.
- Stage and commit Run git add on resolved files, then git commit to complete the merge.
- Verify Run git status to confirm working tree is clean.
- Get help Many conflicts or binary files—ask a teammate or use git mergetool.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- Output of `git status` (showing conflicted files)
- Branch names (yours and the one you merged)
- List of conflicted file paths
Does git status show "merge conflict" or "Unmerged paths"?
Run `git status`. Conflicted files appear under "Unmerged paths" or "both modified."
You can change your answer later.
Do you want to abort the merge or resolve it?
Run `git merge --abort` to cancel. Or open conflicted files and resolve markers.
You can change your answer later.
Abort the merge
Do all conflicted files have no markers?
Remove `<<<<<<<`, `=======`, `>>>>>>>` from each file. Stage with `git add`.
You can change your answer later.
Complete the merge
Get help
Reviewed by Blackbox Atlas
Frequently asked questions
- Why does Git say merge conflict?
- A merge conflict happens when two branches change the same lines in the same file. Git cannot decide which version to keep, so it marks the conflict and asks you to resolve it manually.
- Can I undo a merge that has conflicts?
- Yes. Run `git merge --abort` before you resolve anything. That cancels the merge and returns your branch to the state before you ran `git merge`.
- What do the conflict markers mean?
- `<<<<<<< HEAD` marks your current branch changes. `=======` separates your changes from theirs. `>>>>>>> branch-name` marks the incoming branch changes. Edit the file to keep one version or combine both, then remove all markers.
Rate this guide
Was this helpful?
Thanks for your feedback.