简体   繁体   English

是否有用于“git status”的 Git Hook?

[英]Is there a Git Hook for “git status”?

I'm writing a CLI and I'd like to run something anytime the user checks "git status".我正在编写一个 CLI,我想在用户检查“git status”的任何时候运行一些东西。 Is this possible?这可能吗? From what I've read there does not exist a hook for this.从我读过的内容来看,不存在这个钩子。 Is there a possible workaround?有可能的解决方法吗?

No.不。

There's a complete list of available hooks in the git documentation , and I don't see one there for status . git 文档中有可用钩子的完整列表,但我没有在其中看到status That makes sense, since hooks are usually used to take some action before or after changes are made to the local repository.这是有道理的,因为挂钩通常用于在对本地存储库进行更改之前或之后采取一些行动。 git status doesn't change the state of the repository at all, so there's less reason to run a hook when that command runs. git status根本不会更改存储库的 state,因此在该命令运行时运行挂钩的理由较少。

That said, it's possible to create your own git commands by putting an executable file named git-xxx , where xxx is your command name, somewhere in your path.也就是说,可以通过将名为git-xxx的可执行文件(其中xxx是您的命令名称)放在路径中的某个位置来创建您自己的git命令。 So if you want the status reported differently, you could just create git-mystatus to do what you want.因此,如果您希望以不同的方式报告状态,您可以创建git-mystatus来做您想做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM