Resolving a Simple Two-Line Git Conflict

Learn how to resolve the most basic type of Git merge conflict where two branches edit the same line differently. Understand ours vs theirs markers.

Basic Conflicts

Detailed Explanation

The Simplest Conflict

A two-line conflict is the most common type you will encounter in day-to-day development. It happens when two branches modify the exact same line in a file. Git cannot decide which version to keep, so it wraps both versions in conflict markers.

What It Looks Like

<<<<<<< HEAD
const API_URL = "https://api.example.com/v2";
=======
const API_URL = "https://api.example.com/v3";
>>>>>>> feature/upgrade-api

Breaking Down the Markers

Marker Meaning
<<<<<<< HEAD Start of your current branch's version
======= Divider between the two versions
>>>>>>> feature/upgrade-api End of the incoming branch's version

Resolution Strategies

Accept Ours keeps v2 — appropriate if the API upgrade is not ready. Accept Theirs keeps v3 — appropriate if the upgrade is complete and tested. In many cases, you want to look at the broader context (tests, documentation, deployment status) before deciding.

Prevention Tips

Single-line conflicts are often preventable by communicating changes with your team. If you know a colleague is working on a configuration change, coordinate to avoid editing the same constant in parallel. Small, frequent merges also reduce the chance of conflicts.

Use Case

You are merging a feature branch into main and Git reports a conflict in a configuration file where both branches changed the API endpoint URL.

Try It — Git Conflict Resolver

Open full tool