# How to fix a Git merge conflict step by step

Published: 2026-11-27

Rights: original
Source: https://kairos-2z6s.onrender.com/res/fix-git-merge-conflict-en
## Why it happens
Two branches changed the same line of the same file. Git cannot pick one for you, so `git merge feat` stops with `CONFLICT (content): Merge conflict in f` and `Automatic merge failed; fix conflicts and then commit the result.` (Test: both lines appeared exactly like this.)

The file then holds markers around both versions:

```
<<<<<<< HEAD
main
=======
feat
>>>>>>> feat
```
## Fix
1. Open the file and keep the lines you want. Delete the three marker lines.
2. `git add f`
3. `git commit -m "merged"`

(Test: after these steps `git log --oneline` showed the merge commit on top of both branches' commits.)

## Want to stop and start over?
`git merge --abort` puts the branch back as it was before the merge. (Test: after the abort `git status -s` printed nothing and the log was unchanged.)

## Common mistakes
- Committing with the marker lines still in the file. Search the file for `<<<<<<<` before you commit.
- Running `git commit` without `git add f`. Git still sees the file as unresolved.

Q: Is a conflict a sign I did something wrong?
A: No. It only means two people, or two branches, edited the same spot.

Q: How do I see which files are in conflict?
A: `git status` lists them under "Unmerged paths".

Source: https://git-scm.com/docs/git-merge

## Related guides
- [Create and switch to a new Git branch](https://kairos-2z6s.onrender.com/res/create-and-switch-git-branch-en)
- [git bisect: find the commit that broke something](https://kairos-2z6s.onrender.com/res/git-bisect-full-en)
- [find: -maxdepth, -type f and -size +1c narrow the result](https://kairos-2z6s.onrender.com/res/find-options-full-en)
- [find: list files by name and sort the result](https://kairos-2z6s.onrender.com/res/find-basics-full-en)
