首页 > 解决方案 > 如何抑制 git 消息:致命:此操作必须在工作树中运行

问题描述

当我在 git repo 中运行cd .git && git statusgit 时,只会显示:

fatal: this operation must be run in a work tree.

有没有办法抑制这个错误信息?

另一种情况是在 Zsh 中启用 vcs 后autoload -Uz vcs_info,如果您在.git目录中,则每个命令都会收到此错误消息。

标签: gitversion-controlzsh

解决方案


发现git 社区提供的 git/git-prompt.sh可以使用它。


推荐阅读