我想在 Git 提交之前检查提交消息。
我使用预提交挂钩来执行此操作,但我找不到在中获取提交消息的方法.git/预提交脚本。
我怎样才能得到它?
In the pre-commit
hook, the commit message usually hasn't been created yet 1. You probably want to use one of the prepare-commit-msg
or commit-msg
hooks instead. There's a nice section in Pro Git http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks on the order in which these hooks are run, and what you typically might do with them.
1. The exception is that the committer might have supplied a commit message with -m
, but the message still isn't accessible to the pre-commit
hook, whereas it is to prepare-commit-msg
or commit-msg
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)