Skip to content

Git Quickie: Add Autocorrect To Git

Tired of always misstyping ‘commit’ as ‘comit’ while in a hurry to commit and push? Wouldn’t it be cool if git knew you meant ‘commit’? It can. Read how!

To avoid typos or respectively let them be corrected by your console, you can change the settings of your git client. You can set a value with help.autocorrect. You set it to an integer, representing the time you have to revert the correction, before git executes the command.

For example:

$ git config --global help.autocorrect 20

This will set the time to 2 seconds (1 = 0.1 seconds). Now you make a typo while commiting:

$ git comit

The console will now return a message similar to this one:

WARNING: You called a git command named 'comit', which does not exist. Continuing under the assumption that you meant 'commit' in 2 seconds automatically...

Now you could interrupt git or let it execute the command you meant in the first place 🙂

Published inQuickiesScripting/ Coding

Be First to Comment

Leave a Reply

%d bloggers like this: