gpt4 book ai didi

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

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

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

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