snippetjavascriptTip
Enable autocorrect for mistyped Git commands
Viewed 0 times
enablegitcommandsmistypedautocorrectfor
Problem
Do you find yourself mistyping commands often? Luckily, Git has an autocorrect feature you can enable to automatically fix them. The
By setting the value to an integer, Git will wait for that many tenths of a second before executing the corrected command. For example, setting
Additionally, you can use some keywords to specify the autocorrect behavior, such as
help.autocorrect setting allows you to specify the autocorrect behavior you like.By setting the value to an integer, Git will wait for that many tenths of a second before executing the corrected command. For example, setting
help.autocorrect to 1 will make Git wait for 0.1 seconds before executing the corrected command. Allowed values are between 0 and 50.Additionally, you can use some keywords to specify the autocorrect behavior, such as
never to disable autocorrect, immediate to execute the corrected command immediately, and prompt to ask for confirmation before executing the corrected command.Solution
# Syntax: git config [--global] help.autocorrect <value>
# Enable autocorrect with a 0.1 second delay
git config --global help.autocorrect 1
git sttaus # Runs `git status` instead, after a 0.1 second delay
# Enable autocorrect with a 1 second delay
git config --global help.autocorrect 10
git sttaus # Runs `git status` instead, after a 1 second delayAdditionally, you can use some keywords to specify the autocorrect behavior, such as
never to disable autocorrect, immediate to execute the corrected command immediately, and prompt to ask for confirmation before executing the corrected command.Code Snippets
# Syntax: git config [--global] help.autocorrect <value>
# Enable autocorrect with a 0.1 second delay
git config --global help.autocorrect 1
git sttaus # Runs `git status` instead, after a 0.1 second delay
# Enable autocorrect with a 1 second delay
git config --global help.autocorrect 10
git sttaus # Runs `git status` instead, after a 1 second delay# Syntax: git config [--global] help.autocorrect <value>
# Immediate autocorrect
git config --global help.autocorrect immediate
git sttaus # Runs `git status` immediately
# Prompt for confirmation before autocorrect
git config --global help.autocorrect prompt
git sttaus # Asks for confirmation before running `git status`
# Disable autocorrect
git config --global help.autocorrect never
git sttaus # Does not autocorrectContext
From 30-seconds-of-code: autocorrect
Revisions (0)
No revisions yet.