git中的预取钩子功能

git中的预取钩子功能

本文介绍了git中的预取钩子功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的情况下,我在服务器上维护了一个svn同步的git存储库.我们小组中的所有开发人员都使用此存储库来获取其更新.
在开发人员获取最新更改之前,我找不到一种方法来自动触发"git svn fetch"(或任何其他命令).
我目前的解决方法是安排一个cron作业,该作业每5分钟同步一次与svn相关的更改.
完全可以使用这种预提取挂钩吗?
谢谢

in my scenario i maintain a svn-synchronized git repository on a server.all developers in my group use this repository to get their updates.
i couldn't find a way to trigger an automatic "git svn fetch" (or any other command) before a developer fetches the latest changes.
my current workaround is to have a cron job that syncs in svn related changes every 5 minutes.is it possible to have this kind of a pre-fetch hook at all?
thanks

推荐答案

没有预定义的钩子可以让您完全执行所需的操作.

There is no pre-defined hook that will allow you to do exactly what you want.

如果您的开发人员通过ssh获取数据,则可以为git-upload-pack创建一个包装脚本,该脚本隐藏真实的git-upload-pack并在存储库中调用git svn fetch(同时绝对确保对所有输出和错误进行压缩) ),然后执行真实的git-upload-pack.

If your developers are fetching over ssh, you might be able to create a wrapper script for git-upload-pack which hides the real git-upload-pack and calls git svn fetch on the repository (while being absolutely sure to squash all output and errors) before execing the real git-upload-pack.

尽管如此,但设置起来很健壮.您可能最好为开发人员提供一种方法,使其在远程存储库上手动引起对git svn fetch的调用,并鼓励他们使用替代的fetch别名,该别名先执行此操作(并等待其完成!),然后再进行实际操作.提取.

This might be quite fiddly to set up and make robust, though. You might be better off providing a way for your developers to manually cause a call to git svn fetch on the remote repository and encouraging them to use an alternative fetch alias that does this first (and waits for it to complete!) before doing the real fetch.

这篇关于git中的预取钩子功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 00:58