我最近更新了我的 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/