Home/Signatures/git: did you mean 'commit'?
Search algorithmsCTRL K

git: did you mean 'commit'?

· Levenshtein distance against every git command, with git's own weights
/signatures/did-you-meanbuilt on Binary search
CANDIDATES
42
git subcommands
COMPARED
0
tables filled so far
CELLS
0
computed, m × n each
BEST DISTANCE
—
lowest so far
MATCH
—
the suggestion
row being filledanswer cellfilled
"comit" · 42 commands · git weights · 49 steps
step 0 / 48
WEIGHTS
$ git
RANKING
bash
> git comit
comparing 0 / 42…
CURRENT STEP

"git comit" is not a command. Compare "comit" with each of the 42 commands git knows, with git's weights (swap 0, insert 1, substitute 2, delete 3).

// how it works

git: did you mean 'commit'?

Edit distance counts the fewest insertions, deletions and substitutions that turn one string into another. The dynamic-programming table has one row per character typed and one column per character of the candidate; each cell is the cheapest of three neighbours plus the cost of its own edit, and the bottom-right cell is the answer.

When you mistype a subcommand, git computes this distance from what you typed to every command it knows and suggests the closest. Its weights are not all 1: a swap of two adjacent letters costs 0, an extra letter 1, a wrong letter 2 and a missing letter 3, because those are the mistakes people actually make. Toggle the weights and watch the ranking change.

// edit distance

What to notice

Every candidate costs m × n cells: the table is small, but there are dozens of candidates, so the cells counter is what you pay.
With git's weights 'chekout' is closer to 'checkout' than to anything else, but 'stauts' → 'status' costs 0: a swap is free.
git only suggests when the distance is under its floor of 7; a garbage word gets no suggestion.
Open the algorithm page: Binary searchSearching · Back to /searching/binary-search