Dualo
Git & GitHub

Resolving merge conflicts

Two branches changed the same lines? Git pauses, marks the conflict in the file, and waits for you to choose. Edit, stage, continue.

1 min read

A conflict happens when Git can't auto-merge because two branches changed the same lines in different ways. Git stops, marks the conflicted region in the file, and asks you to resolve it.

Inside the conflicted file, you see this:

<<<<<<< HEAD your version

the other version

feature/login

Your job: open the file, decide what the right content should be (your version, theirs, both, or neither), and delete the markers (<<<<<<<, =======, >>>>>>>). Save the file.

Then: git add <file> (stages the resolution), and continue: git merge --continue (or git rebase --continue if you were rebasing). To bail out: git merge --abort / git rebase --abort.

Tip: most editors (VS Code, JetBrains) show conflicts visually with 'Accept Current / Accept Incoming / Accept Both' buttons — much faster than editing markers by hand.

Practice

You started a merge that conflicts and you want to cancel it (reset to pre-merge state). Command?

Practice

During a merge conflict, take *your* version of `app/config.ts` wholesale (discard the incoming changes). Command?

Grounded on https://git-scm.com/docs/git-merge#_how_conflicts_are_presented

Next up

Remotes — push and pull

A remote is another Git repo, usually on a server. `push` uploads your commits, `pull` downloads theirs. `origin` is the conventional name of the main remote.