- Update in Feb 2025: A patch submitted to the Git mailing list to address an issue was merged. Newer Git versions (2.49+) interpret a
1
as a booleantrue
and run the guessed value immediately. - David's experience: He mistyped
git pushy
and was surprised that Git guessed and ran it. As a semi-professional race car driver, he noticed the short reaction time was impossible for F1 drivers. - How it works originally: Typing an unknown command would show "not a git command" by default. In 2008, Johannes Schindelin introduced a patch to show similar commands and run if there's a close match. Alex Riesen added a patch to make it configurable via
help.autocorrect
(initially a boolean). Junio Hamano suggested making it configurable in deciseconds, and setting it to1
means waiting 100ms. - What it should be set to: The valid values are 0 (default - show suggested command), positive number (run after specified deciseconds), "immediate" (run immediately), "prompt" (show suggestion and prompt for confirmation), and "never" (don't run or show suggestion). "Prompt" is considered more reasonable.
- How it guesses: Git uses a modified Levenshtein distance algorithm with a hardcoded cutoff. It guesses based on similarity, e.g.,
git bass
is close torebase
, butbassa
is not. It also matches based on the end of the string. - My fix: Realizing a simple fix while researching, a patch was written to interpret a
1
as "immediately" instead of waiting 100ms. Junio requested proper interpretation of boolean string values, and a second version of the patch is in progress.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。