Don't Panic!

What is a Conflict?

A conflict happens when two people change the same line of the same file differently. Git doesn't know which one to pick, so it asks you to decide.

Visualizing a Conflict

Both branches modified the same part of the code. Git stops and asks for help.

Anatomy of a Conflict

When Git gets confused, it pauses and asks for help. It marks the file like this:

<<<<<<< HEAD
const buttonColor = "blue"; // Your change
=======
const buttonColor = "red"; // Incoming change
>>>>>>> feature-login

The Markers

  • <<<<<<< : Start of your changes
  • ======= : The divider
  • >>>>>>> : End of incoming changes

How to Fix

  1. Delete the markers.
  2. Choose the code you want (or combine them).
  3. Save the file.

How to Resolve

1

Open the file

Open the conflicting file in VS Code. It usually highlights conflicts for you.

2

Decide

Choose which code is correct. Or combine them if both are needed.

3

Clean up

Delete the markers (<<<<<<<, =======, >>>>>>>). The file should look normal again.

4

Commit

Stage the file (git add) and commit (git commit). You've resolved the conflict!