接收后挂钩从裸回购拉 [英] Post-receive hook to pull from bare repo

查看:118
本文介绍了接收后挂钩从裸回购拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的服务器上,每个项目都有2个文件夹:/ repository和/ htdocs。 Htdocs是存储库的一个副本,这是裸露的回购。每个开发人员都有自己的仓库克隆工作.htdocs可以预览项目给项目经理。



我想设置一个自动接收后挂钩在开发者推送更新时更新htdocs。



我的post-receive hook中有以下内容:

 #!/ bin / sh 
GIT_WORK_TREE = .. / htdocs git pull origin master

然而,当我推送时,我看到以下错误:



任何人都可以告诉我发生了什么问题吗?



请注意,

 #!/ bin / sh 
GIT_WORK_TREE = .. / htdocs git checkout -f

可以工作,但是这有点慢(因为这个项目非常大)。也可能有人在htdocs中做了一些错误修正,如果它们没有提交,它们会在 checkout -f 中丢失。



  GIT_WORK_TREE = .. / htdocs GIT_DIR =。

./htdocs/.git git pull origin master

如果不指定GIT_DIR,那么git相信repo仍然是 repository (裸回购),它可能没有名为 origin 的远程(因此错误信息)。


On our server we have, for each project, 2 folders: /repository and /htdocs. Htdocs being a clone of repository, which is the bare repo. Every developer has his own repository clone to work in. htdocs is there to preview the project to project managers.

I would like to set up a post-receive hook that automatically updates htdocs when updates are pushed from the developers.

I have following in my post-receive hook:

#!/bin/sh
GIT_WORK_TREE=../htdocs git pull origin master

However, when I push, I see following error:

Can anyone tell me what's going wrong?

Note that

#!/bin/sh
GIT_WORK_TREE=../htdocs git checkout -f

works, but this is kinda slow (as the project is pretty big). It is also possible someone made some bugfixes in htdocs that would get lost with checkout -f if they weren't committed.

解决方案

This should work:

 GIT_WORK_TREE=../htdocs GIT_DIR=../htdocs/.git git pull origin master

If you don't specify GIT_DIR, git believe the repo is still "repository" (the bare repo), which might not have a remote named "origin" (hence the error message).

这篇关于接收后挂钩从裸回购拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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