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.

Category
Troubleshooting · Devices & software
Time
5–15 min
Last reviewed
What you'll need
  • Git installed and a repository with a merge in progress
  • Text editor to edit conflicted files

Step-by-step diagnostic

Step 1 of 6
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/file for 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 status shows “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.

  1. Check status Run git status to see which files have conflicts.
  2. Abort or resolve Run git merge --abort to cancel, or open files and resolve markers.
  3. Stage and commit Run git add on resolved files, then git commit to complete the merge.
  4. Verify Run git status to confirm working tree is clean.
  5. 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."

Run `git status`. Good: you see conflicted files listed. Bad: no merge in progress—you may have already resolved or never started a merge.

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.

Abort: Run `git merge --abort`. When you abort then the working tree returns to before the merge. Resolve: Open each conflicted file, remove conflict markers, keep the version you want, then `git add` and `git commit`. Good: merge aborted or resolved. Bad: still in conflict—re-check files for remaining markers.

You can change your answer later.

Abort the merge

Run `git merge --abort`. Confirm you should see "Merge aborted" and the working tree clean.

Do all conflicted files have no markers?

Remove `<<<<<<<`, `=======`, `>>>>>>>` from each file. Stage with `git add`.

Open each conflicted file. Remove all conflict markers. Keep the version you want or combine both. Run `git add` for each file. `git status` should show no "Unmerged paths." Good: all staged. Bad: markers remain—edit and re-add.

You can change your answer later.

Complete the merge

Run `git commit`. Save the default merge message. Confirm you should see "Merge made by the recursive strategy" or similar. Run `git status` to confirm working tree clean.

Get help

If you have many conflicts, binary files, or complex history, ask a teammate or use `git mergetool`. Capture the output of `git status` and the branch names.

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.

Continue to