I would like to setup a pre-commit hook for all git repos to validate syntax errors using jshint and phplint. But the issue is that the git has a feature which can skip pre-commit hook from happening by using --no-verify flag. But i don't need to use that option. Can i prevent that --no-verify flag for git Please suggest a way.
Double-click on Windows Firewall → Protect all network connections → set to Disabled and press Apply.
If you have scripts that execute git commands where you don't want Overcommit hooks to run, you can disable Overcommit entirely by setting the OVERCOMMIT_DISABLE environment variable.
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.
First off: you can't definitively prevent someone from passing the --no-verify
option. That said, it's a good practice to use pre-commit
hooks for linting, and it's a good practice to avoid passing the --no-verify
option without reason.
If, however, you want to make it more cumbersome to pass the --no-verify
option, you could:
pre-commit
;pre-receive
with a non-zero exitcode if this token is missing or invalid. (Examples of things you can do in pre-receive hooks: https://github.com/github/platform-samples/tree/master/pre-receive-hooks)Someone determined to avoid passing --no-verify
could manually do step 1, which is why this isn't 100% effective. I wouldn't recommend setting this up in a professional context, but I'm all for people using the tools at their disposal to instill good habits for themselves, while learning more about git hooks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With