ReadbackLesson 08In progress
2 steps · 32 minutes · one terminal

CONFLICTSBY HAND

Your agent stops on a conflict and asks what to do. Before you can answer you need to know which kind of conflict it is — there are several, they need different resolutions, and two of them do not put markers in the file at all.

What you already know

Retrieval · lessons 04 and 05

Two from memory. The second one is the whole reason this lesson exists.

Answer before you move on

When does git report a conflict rather than merging automatically?

Answer before you move on

During a merge, which side do the ours markers hold?

There is more than one kind

Claim + proof · git status --short

Almost everything written about git conflicts describes exactly one case: two sides edited the same lines, and markers appear in the file. That case is common, and it is the easy one.

Here is a merge that produces three different kinds at once.

Executed, output verbatim
$ git merge feature
Auto-merging config.yml
CONFLICT (content): Merge conflict in config.yml
CONFLICT (modify/delete): legacy.txt deleted in feature and modified in HEAD.  Version HEAD of legacy.txt left in tree.
Auto-merging retry.ts
CONFLICT (add/add): Merge conflict in retry.ts
Automatic merge failed; fix conflicts and then commit the result.

Read the parenthesised words. content, modify/delete, add/add — three names, and git tells you which is which before you open a single file.

And git status --short gives you the same three facts in three characters each. The two-letter codes are the index state for each side: the first letter is ours, the second is theirs (git-status).

Executed, output verbatim
$ git status --short
UU config.yml
UD legacy.txt
AA retry.ts

UU — both modified. UD — we modified, they deleted. AA — both added. A U on either side means unmerged, and the letters say what each side did.

Here is the part everyone has backwards

A conflict is not “markers appeared in a file”. It is a path git refused to resolve. Two of the three above have no markers to read: legacy.txt is sitting in your working tree looking perfectly normal, and it is unmerged.

Predict before you read on

You resolve config.yml and retry.ts, both of which had markers. You do not touch legacy.txt, because it looks fine. You run git commit. What happens?

The first thing to run on any conflict

git status --short. Every unmerged path, with its kind encoded in two letters. Do this before opening an editor — the file that needs the most thought is often the one that looks untouched.

3 of 5 steps remain

The index holds three copies

You have read the first 2 steps in full — a claim and the verification that settles it. The rest of this lesson, and the 9 lessons after it, open when subscriptions do. Nothing that is free today will be taken away then.

Read the free reference
Subscriptions open soon
the free preview stays