1
0
mirror of https://github.com/tiimgreen/github-cheat-sheet.git synced 2025-08-09 09:26:42 +02:00

Improve git auto-correct

Provide more details for the git feature auto-correct.
This commit is contained in:
Dillon Flamand
2018-03-28 21:36:53 -07:00
committed by GitHub
parent a96f4fab81
commit 627fab4879

View File

@@ -974,7 +974,9 @@ Some useful aliases include:
*Some Aliases are taken from [@mathiasbynens](https://github.com/mathiasbynens) dotfiles: https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig*
#### Auto-Correct
If you type `git comit` you will get this:
Git gives suggestions for misspelled commands and if auto-correct is enabled the command can be fixed and executed automatically. Auto-correct is enabled by specifying an integer which is the delay in tenths of a second before git will run the corrected command. Zero is the default value where no correcting will take place, and a negative value will run the corrected command with no delay.
For example, if you type `git comit` you will get this:
```bash
$ git comit -m "Message"
@@ -984,21 +986,23 @@ $ git comit -m "Message"
# commit
```
To call `commit` when `comit` is typed, just enable auto-correct:
Auto-correct can be enabled like this (with a 1.5 second delay):
```bash
$ git config --global help.autocorrect 1
$ git config --global help.autocorrect 15
```
So now you will get this:
So now the command `git comit` will be auto-corrected to `git commit` like this:
```bash
$ git comit -m "Message"
# WARNING: You called a Git command named 'comit', which does not exist.
# Continuing under the assumption that you meant 'commit'
# in 0.1 seconds automatically...
# in 1.5 seconds automatically...
```
The delay before git will rerun the command is so the user has time to abort.
#### Color
To add more color to your Git output: