No, it won't bypass any pushes or commits in the near future, unless:
- You have an alias that adds this by default within your .gitconfig
- You pass this flag every time you push or commit.
Regarding the second point, you need to pass --no-verify every time for this to work.
Option 1 Example
.gitconfig
Adding an alias to your git config (i.e. fcommit for force commit) would apply the --no-verify everytime.
[alias]
fcommit = commit --no-verify
Usage
git fcommit
Answer from steadweb on Stack OverflowNo, it won't bypass any pushes or commits in the near future, unless:
- You have an alias that adds this by default within your .gitconfig
- You pass this flag every time you push or commit.
Regarding the second point, you need to pass --no-verify every time for this to work.
Option 1 Example
.gitconfig
Adding an alias to your git config (i.e. fcommit for force commit) would apply the --no-verify everytime.
[alias]
fcommit = commit --no-verify
Usage
git fcommit
On Unix git config --global core.hooksPath /dev/null works fine.
It's the same as git config:
[core]
hooksPath = /dev/null
Found it with more options here.
git push --no-verify should be configurable
Is there any way of knowing if a commit was pushed with "--no-verify"
Doing `git push --no-verify` instead of `git push --set-upstream origin`
--no-verify for git push
Videos
I know ideally you shouldn't commit with "--no-verify", and we all know there are cases where a fix must be pushed asap, and...welp you know the drill. We're going through some serious changes in our project and cases like this have happened every so often, and we'd like to come up with a protocol to make sure any commit that has skipped the pre-commit should be fixed asap. The first idea that came to mind was some way of flagging a merge request that has any commit that has been pushed with "--no-verify", but ideas are very welcome!
Don't know if this helps but we're hosting our repo in gitlab.
edit: dropped a question mark in the title, sorry
» npm install git-push-no-verify
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:
- generate a verification token and append it to the commit message in
pre-commit; - exit
pre-receivewith 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.
git hooks are a client-side validation (think of it as a frontend), if you want to be sure validation is never skipped you need to do it on CI (backend).
Having said that here's my personal opinion about git hooks: it's a good practice to prevent devs to merge a PR in case linter, tests, etc don't pass. But do it on CI, don't enforce it prematurely on the client side. It will unnecessarily slow down the development process. Allow devs to decide when they want to fix linter issues instead of saying "you can't commit until you make it perfect". That will allow them to focus on solving the problem they are working on instead of having to think in code style standards