Git跳过提交后钩子 [英] Git skip post-commit hook
问题描述
我的仓库中有一个git post-commit钩子.有时候我想跳过运行此钩子.
I have a git post-commit hook in my repo. I want to skip running this hook sometimes.
要跳过预提交钩子,我知道我可以在提交时使用--no-verify标志
To skip pre-commit hook, I know I can use the --no-verify flag while commiting like this
git commit -m "message" --no-verify
但这并不是跳过提交后的钩子.
But this is not skipping post-commit hook.
是否可以跳过提交后的钩子?如果可以,怎么办?
Is it possible to skip post-commit hook? If so how to do it?
推荐答案
来自文档:
-n--no-verify此选项绕过pre-commit和commit-msg挂钩.另请参阅githooks [5].
-n --no-verify This option bypasses the pre-commit and commit-msg hooks. See also githooks[5].
因此,此标志不会跳过提交后的钩子.似乎没有一种简单,干净的方法来跳过此标志.单次操作;您可以只禁用该钩子,然后在提交后再次启用它:
so this flag does not skip the post-commit hook. There doesn't seem to be a simple, clean way to skip this flag. For a one-shot operation; you could just disable the hook and enable it again after your commit:
chmod -x .git/hooks/post-commit # disable hook
git commit ... # create commit without the post-commit hook
chmod +x .git/hooks/post-commit # re-enable hook
这篇关于Git跳过提交后钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!