如何禁用我在 bash shell 中键入 `git commit` 命令的能力?

Bra*_*old 1 bash git

tl;dr:有没有办法让我的 shell 拒绝我输入的任何以 开头的内容git commit?它允许我git commit在其中运行脚本,但不允许我键入的任何命令以该前缀开头。

更多信息:我的团队git用于源代码控制,以及这个名为Commitizen 的包,它在使用git cz命令时在提交历史记录中提供了一个花哨的更改日志/自动版本控制。但是,git commit仍然有效。这对我来说是个问题,因为我有使用普通旧蒸馏器的习惯git commit

Cyr*_*rus 5

我建议创建一个函数:

git() { if [[ "$1" != "commit" ]]; then command git "${@}"; fi; }
Run Code Online (Sandbox Code Playgroud)

或更短:

git() { [[ "$1" != "commit" ]] && command git "${@}"; }
Run Code Online (Sandbox Code Playgroud)

看: help command