我只是希望能够运行它以查看我工作树中的代码是否通过它,而不是实际尝试提交。
答案 0 :(得分:24)
只需通过shell运行pre-commit
脚本:
bash .git/hooks/pre-commit
答案 1 :(得分:7)
只需运行git commit
。您无需在此之前添加任何内容,因此最终您会收到消息no changes added to commit
。
答案 2 :(得分:3)
Per the usage documentation:
If you want to manually run all pre-commit hooks on a repository, run
pre-commit run --all-files
. To run individual hooks usepre-commit run <hook_id>
.
So pre-commit run --all-files
is what the OP is after.