git - 在版本控制上更新 pre_commit Hook 文件

标签 git githooks

我最近更新了我的 pre_commit.sample 文件以在提交时运行 rubocop(重命名为 pre_commit)。

#!/bin/sh
#
# Check for ruby style errors
rake run:rubocop

我错误地认为这会在 pull 更改时在其他开发人员机器上更新。我如何确保 pull 更改的任何人都更新了他们的 pre_commit 文件

谢谢

最佳答案

在 git v2.9 之前,无法在客户端更新钩子(Hook)。

Git v2.9 公开了新配置以允许此操作:

git config [--local] core.hooksPath ...

core.hooksPath By default Git will look for your hooks in the $GIT_DIR/hooks directory. Set this to different path, e.g. /etc/git/hooks, and Git will try to find your hooks in that directory, e.g. /etc/git/hooks/pre-receive instead of in $GIT_DIR/hooks/pre-receive.

The path can be either absolute or relative.
A relative path is taken as relative to the directory where the hooks are run.

This configuration variable is useful in cases where you’d like to centrally configure your Git hooks instead of configuring them on a per-repository basis, or as a more flexible and centralized alternative to having an init.templateDir where you’ve changed default hooks.

关于git - 在版本控制上更新 pre_commit Hook 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40550477/

相关文章:

Git + Drupal 工作流程

git - DVCS 检测代码块移动

git - 绕过 post-receive hook git

git - git中预推和预接收钩子(Hook)的区别?

node.js - 在 WebStorm 和 SourceTree 中使用 NVM 时 Git Hooks 错误

Git 'pre-receive' 钩子(Hook)和 'git-clang-format' 脚本可靠地拒绝违反代码风格约定的推送

python - 将静态 Assets 从本地机器部署到 heroku - 无法打开文件 'manage.py' : [Errno 2] No such file or directory

git - 如何暂时禁用 git http 代理

git-svn : Keep . svn 目录

git - 如何将客户端 Hook 应用于 git 中的所有本地存储库?