azium azium - 2 months ago 26
Git Question

Can't remove / find git hook

Once upon a time I installed some git hooks a la these instructions:

Clone this directory, then run
git config --global init.templatedir $template_dir
. Afterward new repositories will use this directory for templates.

Now I want to remove these hooks. I've unset the template in my
, I've deleted the
folder, but no matter what the hooks still run.

File ".git/hooks/pre-commits/security-scan", line 49, in check_code_diff
code = code.decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 113: ordinal not in range(128)

But I can't seem to find this file anywhere on my machine! Only the sample hooks are in my repository's hooks folder

applypatch-msg.sample pre-push.sample
commit-msg.sample pre-rebase.sample
post-update.sample prepare-commit-msg.sample
pre-applypatch.sample update.sample


From the error message you get, it seems the name of the hook script is security-scan. You should be able find this file by searching through the entire filesystem:

find / -name security-scan 2>/dev/null

I muted stderr to reduce noise. Also, we know for a fact that the file is readable by your user, if it wasn't, it wouldn't be causing issues.

You could remove these files by adding -delete flag. You might want to remove the entire directories too, for that you can use this:

find / -name security-scan -exec sh -c 'rm -fr "$(dirname "{}")"' \; 2>/dev/null