# Git: CONFLICT (content): Merge conflict in file — Automatic merge failed

**Code:** `CONFLICT` · **Category:** Git · **Seen on:** Git

Both branches changed the same lines; Git needs you to choose the final content before completing the merge/rebase.

## Meaning

Git inserts conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) into the file. You edit the file to the desired result, remove the markers, stage it and continue.

## Common causes

- Same lines edited on both branches
- One branch deleted a file the other modified
- Formatting/line-ending changes across the file

## Quick fix

1. `git status` to list conflicted files
2. Edit each file, remove markers, keep the right code
3. `git add <file>` then `git commit` (merge) or `git rebase --continue`
4. Abort if needed: `git merge --abort` / `git rebase --abort`

## Detailed fix by platform

### Git

1. Take one side for a whole file: `git checkout --ours file` or `--theirs file` (note: during rebase “ours” is the branch you’re rebasing onto).
2. Normalize line endings with `.gitattributes` (`* text=auto`) to avoid whole-file conflicts.

## Code examples

### Conflict markers

```text
<<<<<<< HEAD
const timeout = 30;
=======
const timeout = 60;
>>>>>>> feature/retry
```

## How to diagnose

1. **Files** — git status — which files?
2. **Intent** — Which change should win, or a combination?
3. **Tests** — Run tests after resolving

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/git/merge-conflict)
