git pre-status 或 post-status Hook

标签 git bash hook

我想在 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/

相关文章:

仅针对特定子文件夹的 Git 预提交 Hook ?

winapi - Discord如何挂接到特定进程的音频中?

git - 版本化多个不同文件的最佳方式

windows - 'ssh-keygen' 未被识别为内部或外部命令

json - jq - 无法在 while 循环中将对象 append 到数组

linux - 为什么 super 简单的功能在我的 Mac 终端中无法显示 256 色?

git - 确保文件在更新 Hook 中将 CRLF 转换为 LF - 是否会影响性能?

git - 无法连接到 git 远程存储库

linux - 如何存储多个 PAT/密码以供 git 使用?

linux - 如何使用sudo获取运行命令的pid