gpt4 book ai didi

git pre-status 或 post-status Hook

转载 作者:太空狗 更新时间:2023-10-29 13:54:52 25 4
gpt4 key购买 nike

我想在 git status 上运行 linter,但是似乎没有 pre-statuspost-status Hook 。 如何给 git 添加一个钩子(Hook)? fine docs对此事保持可疑的沉默!

我目前正在将我的 linter 和 git status 包装在 Bash 脚本中,但我更喜欢支持我的肌肉内存宏 git status 的解决方案。如果重要的话,我正在运行带有 KDE 4 的 CentOS 7.3。

最佳答案

Git 钩子(Hook)用于(将要)修改存储库或工作树的操作。由于 git status 是只读操作,因此没有钩子(Hook)。

I'm currently wrapping my linter and git status in a Bash script, but I would prefer a solution which supports my muscle-memory-macro git status.

您可以将您的 git 命令包装到以下不需要调整您的肌肉内存的函数中:

git()
{
if [[ $# -ge 1 && "$1" == "status" ]]
then
echo Your git-status pre-hook should be here
fi

command git "$@"
}

关于git pre-status 或 post-status Hook ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41847452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com