对所有当前和将来的回购应用git post-commit挂钩 [英] Applying a git post-commit hook to all current and future repos

查看:137
本文介绍了对所有当前和将来的回购应用git post-commit挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个Git post-commit钩子,它工作正常。但是,我想添加这个钩子来应用于我正在处理的所有当前(和未来)git存储库。我尝试将钩子添加到我的〜/ .git / hooks / 中,而不是在项目目录的钩子目录中,但是,这似乎不起作用。



有没有什么办法可以创建全局的Git钩子,这些钩子将应​​用于我系统上的所有仓库(无需将它们复制到每个项目目录中)?如果不是,那么最好的解决方案是什么 - 可能是一个git-init模板?

解决方案


我想添加这个钩子以适用于我正在使用的所有当前(和未来)git仓库


使用git 2.9+ (2016年6月),你所要做的就是:

$ g $ git config --global core.hooksPath / path / to / my /集中式/挂钩

请参阅更改默认的git挂钩:已经完成了管理集中挂钩。


I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) git repositories I am working on. I tried adding the hook to my ~/.git/hooks/ instead of in the hooks directory in the project directory, however, this did not seem to work.

Is there any way to create global Git hooks that will apply to all repositories on my system (without having to copy them into each project directory)? If not, what would be the best solution going forward -- perhaps a git-init template?

解决方案

I want to add this hook to apply to all current (and future) git repositories I am working on

With git 2.9+ (June 2016), all you would do is:

git config --global core.hooksPath /path/to/my/centralized/hooks

See "change default git hooks": this has been done to manage centralized hooks.

这篇关于对所有当前和将来的回购应用git post-commit挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆