# Resolving Merge Conflicts — Git

Source: https://www.geekswithgeeks.com/en/git/git-conflict-resolution

> What a conflict looks like and how to resolve one by hand.

## When conflicts happen

A conflict occurs when two branches change the **same lines** of the same file differently. Git can't guess which version you want, so it pauses and asks you.

## Conflict markers

Git inserts markers into the file. Edit it to keep the right content, then remove the markers.

```text
<<<<<<< HEAD
const greeting = "Hi";
=======
const greeting = "Hello";
>>>>>>> feature/login
```

## Finish the merge

Once every conflicted file is fixed, stage it and commit to complete the merge.

```bash
git add greeting.js
git commit -m "Merge feature/login, resolve greeting conflict"
```

**Quiz:** A merge conflict happens when...

- [x] Two branches change the same lines differently
- [ ] You forget to run git status
- [ ] A branch is deleted before merging

*Answer:* Two branches change the same lines differently. Git can auto-merge changes to different lines; overlapping edits need a human decision.
