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 commitman page):As commented by Blaise,
-ncan have a different role for certain commands.For instance,
git push -nis actually a dry-run push.Only
git push --no-verifywould skip the hook.Note: Git 2.14.x/2.15 improves the
--no-verifybehavior:See commit 680ee55 (14 Aug 2017) by Kevin Willford (“).
(Merged by Junio C Hamano —
gitster— in commit c3e034f, 23 Aug 2017)Davi Lima points out in the comments the
git cherry-pickdoes not support –no-verify.So if a cherry-pick triggers a pre-commit hook, you might, as in this blog post, have to comment/disable somehow that hook in order for your git cherry-pick to proceed.
The same process would be necessary in case of a
git rebase --continue, after a merge conflict resolution.With Git 2.36 (Q2 2022), the callers of
run_commit_hook()to learn if it got "success" because the hook succeeded or because there wasn’t any hook.See commit a8cc594 (fixed with commit 4369e3a1), commit 9f6e63b (07 Mar 2022) by Ævar Arnfjörð Bjarmason (
avar).(Merged by Junio C Hamano —
gitster— in commit 7431379, 16 Mar 2022)