How to manually run a git pre-commit hook, without attempting a commit?

ε祈祈猫儿з 提交于 2019-12-06 16:34:51

问题


I just want to be able to run it to see if the code in my working tree passes it, without actually attempting a commit.


回答1:


Just run the pre-commit script through shell:

bash .git/hooks/pre-commit



回答2:


There's a Python package for this available here. 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 use pre-commit run <hook_id>.

So pre-commit run --all-files is what the OP is after.



来源:https://stackoverflow.com/questions/48301280/how-to-manually-run-a-git-pre-commit-hook-without-attempting-a-commit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!