在客户端发起一个git钩子 [英] firing a git hook on the client

查看:116
本文介绍了在客户端发起一个git钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了计算机1的回购。在repo上, post-receive 钩子成功触发 git checkout -f 对computer 2 。



现在,在计算机2上面,我想在上面的结帐完成后发射一个钩子。我在computer 2上尝试了一个 post-receive 和一个后结账钩子,但是没有成功。都不会发生。在这种情况下,我可以在计算机2上使用哪个钩子?

您不能只是 git checkout -f ,因为这意味着 repo1 将其内容转储到repo2工作树上:

 #repo1 post-receive hook 
GIT_WORK_TREE = / path / to / repo2 git checkout -f

您需要的是 repo2 来提取repo1内容以更新其内容( repo2 )内容。
另外, repo2 启动更新意味着其他repo2钩子将有机会依次触发。



'pre> #repo1后接收钩
GIT_DIR = /路径/到/ repo2 / git的
GIT_WORK_TREE = /路径/要/ repo2 git pull repo1


I updated "repo" from "computer 1". On "repo", a post-receive hook successfully fires to git checkout -f the changes to "computer 2".

Now, on "computer 2" I want to fire a hook once the above checkout is complete. I have tried a post-receive and a post-checkout hook on "computer 2" but have not been successful. Neither fires. Which hook could I use in this situation on "computer 2"?

解决方案

You cannot just git checkout -f, because that means repo1 is dumping its content on repo2 working tree:

 # repo1 post-receive hook
 GIT_WORK_TREE=/path/to/repo2 git checkout -f

What you need is for repo2 to pull repo1 content in order to update its (repo2) content.
Plus, the fact that repo2 initiates the update means that other repo2 hooks will have a chance to be triggered in turn.

 # repo1 post-receive hook
 GIT_DIR=/path/to/repo2/.git
 GIT_WORK_TREE=/path/to/repo2 git pull repo1

这篇关于在客户端发起一个git钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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