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:
14
README.md
14
README.md
@@ -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*
|
*Some Aliases are taken from [@mathiasbynens](https://github.com/mathiasbynens) dotfiles: https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig*
|
||||||
|
|
||||||
#### Auto-Correct
|
#### 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
|
```bash
|
||||||
$ git comit -m "Message"
|
$ git comit -m "Message"
|
||||||
@@ -984,21 +986,23 @@ $ git comit -m "Message"
|
|||||||
# commit
|
# 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
|
```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
|
```bash
|
||||||
$ git comit -m "Message"
|
$ git comit -m "Message"
|
||||||
# WARNING: You called a Git command named 'comit', which does not exist.
|
# WARNING: You called a Git command named 'comit', which does not exist.
|
||||||
# Continuing under the assumption that you meant 'commit'
|
# 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
|
#### Color
|
||||||
To add more color to your Git output:
|
To add more color to your Git output:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user