Git Autocorrect

Git

If you work with the command line often, chances are you use Git from the command line as well. How often do you find yourself mistyping a Git command only to have to type it all over again? By using Git autocorrect, we can alleviate this problem!

By default, Git will offer you one or more suggestions in the event that you type something that could be a match to an existing command. Did you know that you can have Git automatically execute a suggested command?

Here is the excerpt from the official Git documentation:

help.autocorrect
Automatically correct and execute mistyped commands after waiting for the given number of deciseconds (0.1 sec). If more than one command can be deduced from the entered text, nothing will be executed. If the value of this option is negative, the corrected command will be executed immediately. If the value is 0 – the command will be just shown but not executed. This is the default.

So basically, if you just set the autocorrect value to 1, it will automatically execute a Git command if there is only one suggestion.

Git Configuration

Run this command to set it up:

git config --global help.autocorrect 1

Credit

Thanks to Chris Davis for this tip!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.