Git - Autocorrect spelling
You might sometimes do:
git pusj ## instead of push
Git will reply with:
git: 'pusj' is not a git command. See 'git --help'.
Did you mean this?
push
But wouldn't do anything..
To make it fall back to the closest action (which is what you really wanted it to do), add:
git config --global help.autocorrect 1
And now you'll get:
WARNING: You called a Git command named 'pusj', which does not exist.
Continuing under the assumption that you meant 'push'
in 0.1 seconds automatically...
And command will execute as hoped !
Credit and do not miss on Zach Holman's:
http://www.youtube.com/watch?v=Foz9yvMkvlA
Written by Avner Cohen
Related protips
9 Responses
Couldn't make it work using: git config --global help.autocorrect 1
Had to edit my .gitconfig and add it manually.
Great tip, thanks!
This seems dangerous...which makes it AWESOME ;)
Great tip! I'm glad that I won't need to fight with my crazy fingers anymore. Thanks!
For my slowness 1 sec is a little bit short, but I asume that changing help.autocomplete 1 to something higher will solve that.
thanks
Note that the 1
does not equate to one second, rather 0.1 seconds. Use 10
for one second.
How tight, or accurate, are the autocorrects? Are there any obvious scenarios that would result in an autocorrect executing that isn't the actual command you intended to run? I don't have a great example, but clearly typing "pusj" = "push".
Never had a problem with that. git docs are saying: "If more than one command can be deduced from the entered text, nothing will be executed.".
I don't know for sure but I believe a basic algorithm such as levenshtein distance is used. also, there is pretty much nothing that can not be undone in Git using the reflog, so I see no risk here whatsoever.
Cool. Thanks for the quick response, avnerner.
Dangerous case found by a friend, "git resert" ^^ . Very likely with Azerty layout.