我只是希望能够运行它以查看我的工作树中的代码是否通过它,而不实际尝试提交。
只需通过shell运行pre-commit
脚本:
bash .git/hooks/pre-commit
这个可用的here有一个Python包。根据usage documentation:
如果要在存储库上手动运行所有预提交挂钩,请运行
pre-commit run --all-files
。要运行单个钩子,请使用pre-commit run <hook_id>
。
所以pre-commit run --all-files
就是OP所追求的。