我打字
git puhs
Run Code Online (Sandbox Code Playgroud)
而git说:
kristian@office:~/myrepo$ git puhs
git: 'puhs' is not a git command. See 'git --help'
Did you mean this?
push
Run Code Online (Sandbox Code Playgroud)
如果只有一个建议,那么使git只需执行建议命令的配置设置是什么?
jam*_*san 148
根据git-config(1),你想要help.autocorrect
适当地设置.例如,git config --global help.autocorrect 5
在运行命令之前将使其等待半秒钟,以便您可以首先看到该消息.
Ben*_*Ben 24
自动更正是很好的,但我的强迫症自我需要更多的控制正在发生的事情.所以,我写了一个直截了当的脚本,只选择git提供的第一个建议.您在失败的命令之后运行脚本,并使用内置的bash历史记录替换"bang bang"语法.此外,如果您键入的内容可能包含多个命令,则此命令允许您选择除第一个选项之外的其他选项.
看起来像这样,
kristian@office:~/myrepo$ git puhs
git: 'puhs' is not a git command. See 'git --help'
Did you mean this?
push
kristian@office:~/myrepo$ idid !!
Counting objects: 18, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.17 KiB, done.
Total 10 (delta 6), reused 0 (delta 0)
Run Code Online (Sandbox Code Playgroud)
另外,用两个惊叹号键入任何内容都很有趣.所以奖金.
bst*_*rre 17
作为help.autocorrect的替代方法:如果你一直使用相同的拼写错误,你可以在.gitconfig文件中为它们创建别名
[alias]
puhs = push
Run Code Online (Sandbox Code Playgroud)
(我也使用shell别名,我似乎永远无法mkae^H^H^H^Hmake
正确输入.)