Sangam-Git

Merge conflicts: when Git needs your help

A merge conflict happens when two branches changed the same lines of the same file in different ways. Git can combine most changes on its own, but when two edits clash, it stops and asks a human to decide. That human is you — and it's easier than it looks.

Why it happens

Say the price label in your app said ₹99. You changed it to ₹149 on your branch. Meanwhile your teammate changed the same line to ₹129 on main. When you merge, Git sees two different answers for one line and can't pick. So it pauses and marks the spot.

This is not an error you did wrong. It's Git being careful instead of silently throwing away someone's work.

What a conflict looks like

Git edits the file and inserts markers around the clashing part:

<<<<<<< HEAD
price = "₹129"
=======
price = "₹149"
>>>>>>> feat/new-pricing

Read it like this:

  • Between <<<<<<< HEAD and ======= is the version already on your current branch (main).
  • Between ======= and >>>>>>> is the version coming from the other branch.

How to resolve it

You simply edit the file to what it should be, and delete the marker lines. Maybe the right answer is ₹149, maybe ₹129, maybe something new. You decide:

price = "₹149"

No more <<<<<<<, =======, or >>>>>>> lines. Then tell Git you've settled it:

git add checkout.js
git commit

That's it — the merge is complete.

A calm, step-by-step recipe

  1. Run git status. Git lists the files with conflicts, under "Unmerged paths."
  2. Open each one. Find the <<<<<<< markers.
  3. Edit the section to the correct final version. Remove all three marker lines.
  4. git add the file.
  5. When every conflicted file is fixed, git commit to finish the merge.

If you get scared halfway and want to bail out entirely:

git merge --abort

This returns you to exactly where you were before the merge. Nothing lost. Take a breath and try again.

How to have fewer conflicts

  • Pull often. The longer your branch drifts from main, the more likely two people touched the same lines.
  • Keep branches small and short-lived. A branch that lives for one day rarely conflicts; one that lives for a month often does.
  • Talk to your team. If you and a teammate are both rewriting the payments module, coordinate.

On Sangam-Git

When a pull request has conflicts, Sangam-Git tells you clearly: "This branch has conflicts that must be resolved locally before merging." You resolve them on your laptop using the recipe above, push again, and the PR becomes mergeable.

Reassurance: every professional engineer resolves conflicts regularly. It's a normal part of teamwork, not a sign that something broke. The markers look scary once; after that, they're routine.