本文介绍了"裸" Git仓库:我怎样才能让阿帕奇总是"见"最新的承诺?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经有了一个服务器上的一个裸Git仓库,一个Web门户项目。一些程序员,设计师,等等几十个执行从/到它。

We've got a "bare" git repository on a server, for a Web portal project. Several programmers, designers, etc... perform dozens of push and pull from/to it.

现在我们要测试的服务器本身的项目,并始终测试最后通过安装在同一台机器裸Git仓库,存储在Apache Web服务器提交。

Now we want to test the project on the server itself, and always test the last commit through an Apache web server which is installed on the same machine the "bare" git repository is stored in.

怎能'unbare资料库,并让工作目录包含的总是最后一次提交从最后得出

How can we 'unbare' the repository, and let the working directory contain always and only the last commit deriving from the last push?

或者任何其他旨在达到相同的结果

Or anything else aiming to achieve the same result?

推荐答案

您可以使用后收到钩做了 git的拉你的 Web服务器文档根目录/存储库。

You can use a post-receive hook to do a git pull inside your webserver document root/repository.

在你的裸库

in your bare repositorydo

mv hooks/post-receive.sample hooks/post-receive
chmod +x .git/hooks/post-receive

后收到的应该是类似

the post receive should be something like

#!/bin/sh
WEB_ROOT='/var/www/project'
cd $WEB_ROOT
git pull

一个更优雅的不涉及Web服务器区域是一个Git仓库,你也可以查看有关挂钩

A more elegant solution that doesn't involve that the web server area being a git repository, you can also review the git documentation about hooks

注:如果您使用简单的解决方案,请确保您的网络服务器不符合的.git目录,这将给一些黑客/饼干访问该网站源$ C ​​$ C

Note: if you use the simple solution, please make sure that your webserver doesn't serve the .git directory, this would give some hackers/crackers the access to the website source code!

这篇关于"裸" Git仓库:我怎样才能让阿帕奇总是"见"最新的承诺?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!