Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I suppress git hook e.g. prepare-commit-msg via git command line argument?

Tags:

git

In some situation I want to not have the .git hooks to fire when I am committing a change e.g. prepare-commit-msg

Is there a easy way to suppress them via command line (maybe similar to --no-verify)

like image 912
Anthony Kong Avatar asked Dec 11 '25 04:12

Anthony Kong


1 Answers

The best I could do (and at least this does answer the question) is get the parent's command line and look for '-n' or '--no-verify' passed to it.

if ps -o args= $PPID | grep -E -q ' --no-verify| -n | -n$' ; then
  : # they skipped the commit-msg hook, so skip this hook too!
else
  : # do your hook code here
fi

I'm sure there's better code out there, I just could NOT find any examples!

like image 70
johnnyB Avatar answered Dec 12 '25 18:12

johnnyB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!