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
For those very beginners who has spend few hours for this commit (with comment and no verify) with no further issue
git commit -m "Some comments" --no-verify
From man githooks:
pre-commit
This hook is invoked by git commit, and can be bypassed with --no-verify option. It takes no parameter, and is invoked before obtaining the proposed commit log message and making a commit. Exiting with non-zero status from this script causes the git commit to abort.
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-commithook"
git commit" used to discard the index and re-read from the filesystem just in case thepre-commithook has updated it in the middle; this has been optimized out when we know we do not run thepre-commithook.
Davi Lima points out in the comments the git cherry-pick does 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.