IN-Decent

Re-decentralizing internet with free software

Auto-correct Typos in Git Commands

Posted at — Jan 9, 2021

Git by default will suggest corrections for commands with typos as below.

git sttas
git: 'sttas' is not a git command. See 'git --help'.

The most similar command is
        status

It also has a feature to run the suggestion automatically. This feature can be enabled by below configuration option

git config --global help.autocorrect 10

Above configuration option accepts a time parameter which tells git to wait for specified time and then run the suggestion. This is useful in case a wrong command is going to be run and user needs to cancel it.

Note: Time parameter accepted is in deci-seconds(1 tenths of a second).

After setting this option, git will automatically run status command for same input as above.

git sttas
WARNING: You called a Git command named 'sttas', which does not exist.
Continuing in 1.0 seconds, assuming that you meant 'status'.
On branch master
Your branch is up to date with 'origin/master'.

This feature can be disabled by setting time to 0 seconds.

References:

  1. Git scm book