linux - 无法删除/找到 git hook

标签 linux git githooks

有一次我按照这些说明安装了一些 git hooks:

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

现在我想删除这些钩子(Hook)。我已经取消了 .gitconfig 中的模板设置,删除了 .git-templates 文件夹,但无论什么钩子(Hook)仍然运行。

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)

但我似乎在我的机器上任何地方都找不到这个文件!我的存储库的 hooks 文件夹中只有示例 Hook

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

最佳答案

从您收到的错误消息来看, Hook 脚本的名称似乎是security-scan。您应该能够通过搜索整个文件系统找到该文件:

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

我将 stderr 静音以减少噪音。此外,我们知道您的用户可以读取该文件,如果不能读取,也不会导致问题。

您可以通过添加 -delete 标志来删除这些文件。 您可能也想删除整个目录, 为此,您可以使用这个:

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

关于linux - 无法删除/找到 git hook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40809978/

相关文章:

git - 如何解释和使用 Github 提交页面?

git - 使用 Nginx 和 Phusion Passenger 将 rails Gitlab 项目自动部署到子域

git - 为什么在命令 `master` 中包含 `git fetch upstream master` ?

git - 除了 core.hooksPath 全局 Hook 之外,如何运行本地 Git 项目 Hook ?

git - 使用裸存储库 Hook 将服务器恢复到过去的提交

linux - 删除多行中的重复字符串

Linux 上的 java.rmi.NoSuchObjectException

git - 跨平台 git 钩子(Hook)

linux - grep 和 ls : 'l' flag not supported for ls when used with xargs?

linux - 如何突破 smtp 限制?