跳过Git提交钩子 [英] Skip Git commit hooks
问题描述
我正在寻找一个在Python代码中寻找打印语句的git钩子。如果找到了打印语句,它会阻止git提交。
我想覆盖这个钩子,我被告知有一个命令可以这样做。我一直无法找到它。任何想法? 可能(来自 git commit
手册页):
git commit --no-verify
-n
--no-verify
此选项绕过预先提交和提交msg挂钩。另请参阅 githooks(5)。
由于评论对于某些命令, Blaise , -n
可以具有不同的角色。
例如, git push -n
实际上是一个干运行推送。
只有 git push --no-verify
会跳过钩子。 / p>
注意:Git 2.14.x / 2.15可以改善--no-verify行为:
请参阅提交680ee55 (2017年8月14日) Kevin Willford(``)。
(由 Junio C Hamano - gitster
- 在 commit c3e034f ,2017年8月23日)
如果没有
pre-commit
钩子
,则跳过放弃索引
git commit
用于放弃索引并重新读取文件系统
,以防pre-commit 钩已在中间更新它;当我们知道我们不运行 pre-commit
钩子时,这个
已经被优化了。
I'm looking at a git hook which looks for print statements in Python code. If a print statement is found, it prevents the git commit.
I want to override this hook and I was told that there is a command to do so. I haven't been able to find it. Any thoughts?
Maybe (from git commit
man page):
git commit --no-verify
-n
--no-verify
This option bypasses the pre-commit and commit-msg hooks. See also githooks(5).
As commented by Blaise, -n
can have a different role for certain commands.
For instance, git push -n
is actually a dry-run push.
Only git push --no-verify
would skip the hook.
Note: Git 2.14.x/2.15 improves the --no-verify behavior:
See commit 680ee55 (14 Aug 2017) by Kevin Willford (``).
(Merged by Junio C Hamano -- gitster
-- in commit c3e034f, 23 Aug 2017)
commit
: skip discarding the index if there is nopre-commit
hook"
git commit
" used to discard the index and re-read from the filesystem just in case thepre-commit
hook has updated it in the middle; this has been optimized out when we know we do not run thepre-commit
hook.
这篇关于跳过Git提交钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!