如何在 gitkraken 中禁用 git 钩子?

How to disable git hooks in gitkraken?

我正在处理一个配置了 git 挂钩的项目。很遗憾。添加它是为了防止初级或无头开发人员将 CI-check-failing 代码提交到他们的分支。

我就是其中之一,我忽略了 git 与 HUSKY_SKIP_HOOKS 环境变量的挂钩,但对我来说它在 GitKraken 中不起作用。

你知道如何忽略 GitKraken 中的 git 钩子吗?

你在使用这样的命令指令吗HUSKY_SKIP_HOOKS=1 git <command> ...?

您可以像 HUSKY_SKIP_HOOKS=1 一样使用它,但也可以 HUSKY_SKIP_HOOKS=true

你也可以绕过命令行中的提交挂钩:git commit -m "bla bla" -n.

如果长时间无法运行挂钩,也可以使用core.hooksPath git配置选项:

git -c core.hooksPath=/dev/null checkout master
git -c core.hooksPath=/dev/null pull
git -c core.hooksPath=/dev/null commit ...
git -c core.hooksPath=/dev/null push
...

并且(只是说),SourceTree 有一个界面选项可以跳过提交挂钩。据我所知Git Kraken 没有。

好吧,我确实收到了他们支持的回复,这对我有用。

Additionally, you should still be able to disable these hooks from executing. You will need to change the chmod permissions for the files, which reside under local_repo/.git/hooks.

chmod -x .git/hooks/*

它对我有用。

遗憾的是,似乎没有从 GitKraken 中执行此操作的简单方法。正如其他人指出的那样,您应该正常传递 Husky 环境变量。但这里有一个保证简单的解决方案,它将始终有效。我目前正在使用它来清理一些旧存储库。

# Temporarily wipe husky
npm uninstall husky

# Clear out the husky package changes so we don't accidentally commit them
git reset --hard HEAD

当你在 GitKraken 中完成后,重新安装 husky。

npm install