When I typo a git command, such as typing git git checkout myfile (note the extra "git") I get the following output:
WARNING: You called a Git command named 'git', which does not exist.
Continuing under the assumption that you meant 'init'
in 0.1 seconds automatically...
usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]
So git assumes I meant init, and gives me all of 0.1 seconds to see the mistake before it moves forward. Not cool git!
How do I turn this "feature" off?
To see the setting of autocorrect, type:
git config help.autocorrect
Per the docs:
help.autocorrect is actually an integer which represents tenths of a second. So if you set it to 50, Git will give you 5 seconds to change your mind before executing the autocorrected command.
To turn this off, use the command:
git config --global help.autocorrect 0
FWIW, you may also use -c help.autocorrect=0 as a parameter to any Git command. For example:
git -c help.autocorrect=0 svn find-rev 5e2272613fa
It is useful for scripts as you don't modify the environment you are running in.
In this case, unless git-svn is installed, Git would fail to recognize the svn command and try to fall back to serve instead, which might be disastrous in a script.
The up-to-date way to turn that off (in 2020) is with Git 2.30 (Q1 2021): "git $cmd $args, when $cmd is not a recognised subcommand, by default tries to see if $cmd is a typo of an existing subcommand and optionally executes the corrected command if there is only one possibility, depending on the setting of help.autocorrect.
The users can now disable the whole thing, including the cycles spent to find a likely typo, by setting the configuration variable to 'never'.
See commit 644bb95 (25 Nov 2020) by Drew DeVault (ddevault).
(Merged by Junio C Hamano -- gitster -- in commit 78abcff, 14 Dec 2020)
help.c:help.autocorrect=nevermeans "do not compute suggestions"Signed-off-by: Drew DeVault
While
help.autocorrectcan be set to 0 to decline auto-execution of possibly mistyped commands, it still spends cycles to compute the suggestions, and it wastes screen real estate.Update
help.autocorrectto accept the string "never" to just exit with error upon mistyped commands to help users who prefer to never see suggested corrections at all.While at it, introduce "
immediate" as a more readable way to immediately execute the auto-corrected command, which can be done with negative value.
git config now includes in its man page:
If git detects typos and can identify exactly one valid command similar to the error, git will automatically run the intended command after waiting a duration of time defined by this configuration value in deciseconds (0.1 sec).
- If this value is 0, the suggested corrections will be shown, but not executed.
- If it is a negative integer, or "
immediate", the suggested command is run immediately.- If "never", suggestions are not shown at all.
The default value is zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With