1

有时我打错了我真正的意思:

whunt$ git statsu
git: 'statsu' is not a git command. See 'git --help'.

Did you mean this?
    status

您可以通过更改git config中的 help.autocorrect 来告诉 git 只做它建议的事情。但有时我打错了我不想让 git 自动为我运行的破坏性操作:

whunt$ git checkoot some/file
git: 'checkoot' is not a git command. See 'git --help'.

Did you mean this?
    checkout

所以真的,与其运行它认为我想要的,我宁愿让 git 在它不理解命令时告诉我状态。有谁知道如何做到这一点?

4

2 回答 2

3

使用别名。

我正在使用 zsh,只需将以下内容添加到 ~/.zshrc。或 ~/.bashrc 如果仅使用 Bash。

alias gs = 'git status'

现在,如果仍然拼写错误,您可以责怪您的键盘。

添加

这是我所有的 git 别名,以避免你们更多的错字:)

alias gs="git status"
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gcm='git commit -m'
alias gd='git diff'
alias go='git checkout '
alias gh='git hist'
alias gk='gitk --all&'
alias gx='gitx --all'
于 2013-03-13T16:49:16.527 回答
1

除了 Billy 的 shell 别名,如果您愿意,您还可以在 git 本身中创建别名。

git config --global alias.statsu status
git config --global alias.checkoot checkout

你让它听起来像你倾向于犯同样的错别字,所以也许为它们详尽地创建别名并不是太不方便或不切实际。

于 2013-03-14T01:28:26.733 回答