guides/

Diff guides

How text comparison works, how to read the results, and which options to use when.

01 · guide/how-diff-works

How Does diff Find Differences? — LCS and the Myers Algorithm

A plain explanation of how diff finds the differences between two texts: the longest common subsequence (LCS), edit scripts, the Myers O(ND) algorithm, and line-level versus word-level comparison.

02 · guide/diff-algorithms

Myers, Patience, Histogram — Comparing Diff Algorithms

How each value of git diff's --diff-algorithm option (myers, minimal, patience, histogram) works and why their results differ, with examples.

03 · guide/read-unified-diff

How to Read a Unified Diff (Patch) — A Guide for Code Review

Walk through git diff and patch files with examples: the --- and +++ headers, the numbers in @@ hunk headers, context lines, the No newline at end of file marker, and diff --git extended headers.

04 · guide/whitespace-options

Whitespace Ignore Options Explained — diff -b, -w, -B, -Z and Their git Equivalents

The exact differences between ignoring trailing whitespace, ignoring the amount of whitespace (-b), ignoring all whitespace (-w), ignoring blank lines (-B), and ignoring case, compared with GNU diff and git options and examples.

05 · guide/compare-documents

Comparing Documents and Contracts — How to Find Every Difference Between Two Versions

Steps and tips for comparing a draft with its revision, or the contract you sent with the one that came back, as text: choosing space-separated or character units, cleaning up PDF line breaks, and a contract review checklist.

06 · guide/json-diff

How to Compare JSON — Sorting Keys and Normalizing

How to eliminate false differences caused by key order, indentation, and number notation when comparing two JSON documents, plus array order, large integers, and how this differs from JSON Patch.

07 · guide/line-endings

Line Endings (CRLF, LF) and Invisible Differences — When Every Line Shows as Changed

The causes of diffs where every line differs even though the files look the same — CRLF vs LF line breaks, the final newline, BOM, tabs vs spaces, special spaces, Unicode normalization — and how to fix them.