If there a way to specify exactly which git-hook
to skip when using --no-verify
? Or is there another flag other than --no-verify
to accomplish this? Perhaps just a flag to only skip pre-commit
?
I have two hooks that I regularly use, pre-commit
and commit-msg
. pre-commit
runs my linting, flow check, and some unit tests. commit-msg
appends my branch name to the end of the commit message.
There are times that I would like to --no-verify
the pre-commit
but would still like to have commit-msg
run.
There seem to be a lot of SO posts similar to this, but nothing quite like selective skipping with --no-verify
.
Skipping
If you are able to modify the hooks, you can add a toggle for each one.
Example of a specific validation toggle from
pre-commit.sample
:So to enable toggling the entire
pre-commit
hook, this could be added to the beginning of it:Usage example:
Aliasing
Note: Both types of aliases break tab completion.
A
git alias
could simplify this:With that, you could commit and skip the hook with the following invocation:
You could also use a shell
alias
(in e.g.:~/.bashrc
):Usage example: