Git钩子脚本可以与存储库一起管理吗? [英] Can Git hook scripts be managed along with the repository?

查看:86
本文介绍了Git钩子脚本可以与存储库一起管理吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想制作一些我们可以共享的基本钩子脚本 - 例如预格式化提交消息。 Git的钩子脚本通常存储在< project> /。git / hooks / 下。但是,这些脚本不会在人们进行克隆时传播,并且它们不受版本控制。

有没有一种方法可以帮助每个人获得正确的钩子脚本?我可以让这些钩子脚本指向版本控制的脚本吗?

解决方案

理论上,您可以创建一个 hooks 目录(或者你喜欢的任何名字)放在你的项目目录中,然后用 .git / hooks 。当然,每个克隆回购的人都必须设置这些符号链接(尽管你可能会非常喜欢并且有一个部署脚本,克隆人可以运行它们来半自动地设置它们)。


We'd like to make a few basic hook scripts that we can all share -- for things like pre-formatting commit messages. Git has hook scripts for that that are normally stored under <project>/.git/hooks/. However, those scripts are not propagated when people do a clone and they are not version controlled.

Is there a good way to help everyone get the right hook scripts? Can I just make those hook scripts point to version controlled scripts in my repo?

解决方案

Theoretically, you could create a hooks directory (or whatever name you prefer) in your project directory with all the scripts, and then symlink them in .git/hooks. Of course, each person who cloned the repo would have to set up these symlinks (although you could get really fancy and have a deploy script that the cloner could run to set them up semi-automatically).

这篇关于Git钩子脚本可以与存储库一起管理吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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