使用git发布到网站 [英] Using git to publish to a website

查看:119
本文介绍了使用git发布到网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用本指南在我推送到远程原始git存储库时使用git在我的网站上自动发布我的更改:

http://www.lwp.ca/james/2010/03/using-git-to -manage-online-website-projects /
$ b 这是我的/ hooks / post-update文件:

  cd ../../public_html/dir/wbg 
env -i git pull

以下是我的目录结构:

/home/git/wbg.git< - 我的远程git存储库 p>

/ home / public_html / dir / wbg < - 我的网页资料夹



当我运行

  git push origin master 



存储库更新,但我的web文件夹仍然是空的。任何想法?编辑:如果任何未来的流量看到这一点,我真正的问题是,你的远程起源和你的目标网站目录必须是git存储库。你不能只是将它设置为将你的项目复制到一个新文件夹,除非该文件夹也是一个git repo。

这不是很多,但我可以报告,我成功地使用了类似的方法。



出于我的目的,我将我的裸服务器存储库称为 Hub和我的面向网络的存储库Prime。确保你已经在你的服务器htdocs目录(Prime)中正确地初始化了一个git仓库,并且将这些改变推送到裸存储库(Hub)或者将它们拉入。



这是我使用的更新后的钩子,它位于我的Hub仓库的钩子目录中:

 <!c $ c>#!/ bin / sh 

echo
echo***将更改换成Prime
echo

cd / path / to / htdocs / ||退出
取消设置GIT_DIR
git拉中心大师

执行git-update-server-info

确保这是可执行的!如果有疑问,只需编辑 post-update.sample 文件并在完成后删除 .sample 扩展名。回显的文字给出了很好的反馈,即复制实际上正在发生。如果你没有看到那些文字,那么它就不会拉动这些变化。如果您不打算调用远程存储库hub,请将其替换为origin或您决定使用的任何内容。



作为预防措施,以便我Prime和本地版本库不会出现过度失衡,我将它作为我的Prime post-commit 钩子:

 #!/ bin / sh 

echo
echo***对Hub进行更改
echo

git push hub

然后,我可以将更改从Hub转移到本地存储库中。 / p>

I used this guide to use git to autopublish my changes on my website when I push to my remote origin git repository:

http://www.lwp.ca/james/2010/03/using-git-to-manage-online-website-projects/

Here's my /hooks/post-update file:

cd ../../public_html/dir/wbg
env -i git pull

Here's my directory structure:

/home/git/wbg.git <-- my remote git repository

/home/public_html/dir/wbg <-- my web folder

When I run

git push origin master

The repository updates but my web folder is still empty. Any ideas?

Edit: if any future traffic sees this, my real problem was that BOTH your remote origin AND your destination website directory must be git repositories. You can't just set it up to copy your project to a new folder unless that folder is also a git repo.

解决方案

Not a lot to go off of here, but I can report that I successfully use a similar method to this.

For my purposes, I call my bare server repository the "Hub" and my web-facing repository the "Prime". Make sure that you have properly initialized a git repository in your server htdocs directory (Prime) and have either pushed the changes to the bare repository (Hub) or pulled them in.

This is the post-update hook I use, which is in my Hub repository's hooks directory:

#!/bin/sh

echo
echo "*** Pulling changes into Prime"
echo

cd /path/to/htdocs/ || exit
unset GIT_DIR
git pull hub master

exec git-update-server-info

Make sure this is executable! If in doubt, just edit the post-update.sample file and remove the .sample extension when done. The echoed text gives nice feedback that the copying is actually taking place. If you don't see that text, then it's not pulling the changes. And if you're not going to call your remote repository "hub", replace it with "origin" or whatever you decide to use.

As a precaution so that my Prime and local repositories don't get too out of whack, I have this as my Prime post-commit hook:

#!/bin/sh

echo
echo "*** Pushing changes to Hub"
echo

git push hub

Then I can just pull the changes from Hub into my local repository.

这篇关于使用git发布到网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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