使用 git 发布到网站
当我推送到远程源 git 存储库时,我使用本指南使用 git 自动发布我在网站上的更改:
http://www.lwp.ca/james/2010/03/using-git-to-manage-online-website-projects/
这是我的/hooks/更新后文件:
cd ../../public_html/dir/wbg
env -i git pull
这是我的目录结构:
/home/git/wbg.git <-- 我的远程 git 存储库
/home/public_html/dir/wbg <-- 我的 Web 文件夹
当我运行
git push origin master
存储库时更新,但我的 Web文件夹仍然是空的。有什么想法吗?
编辑:如果任何未来的流量看到这一点,我真正的问题是您的远程源和目标网站目录都必须是 git 存储库。您不能只是将其设置为将项目复制到新文件夹,除非该文件夹也是 git 存储库。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在 http://toroid.org/ams/git-website-howto< 找到更好的替代方案< /a> 只使用一个 git 存储库,并允许所有元数据和以前的历史记录保留在 DocumentRoot 之外。
您使用的指南和我将推荐人链接到另一篇文章的指南都是基于的,但我链接的指南似乎是在 #git IRC 频道中引导新用户的首选指南。
You can find a better alternative at http://toroid.org/ams/git-website-howto that only uses one git repository, and allows all metadata and previous history to remain outside of the DocumentRoot.
The guide you used and the one I linked referrer to another article both are based on, but the one I linked seems to be the preferred one to direct new users to in the #git IRC channel.
这里没什么可说的,但我可以报告说,我成功地使用了与此类似的方法。
出于我的目的,我将裸服务器存储库称为“Hub”,将面向 Web 的存储库称为“Prime”。确保您已在服务器 htdocs 目录 (Prime) 中正确初始化 git 存储库,并将更改推送到裸存储库 (Hub) 或将其拉入。
这是
post-update
挂钩我使用的,它位于我的 Hub 存储库的 hooks 目录中:确保它是可执行的!如果有疑问,只需编辑
post-update.sample
文件并在完成后删除.sample
扩展名。回显的文本提供了良好的反馈,表明复制实际上正在发生。如果您没有看到该文本,则说明它不会拉动更改。如果您不打算将远程存储库称为“hub”,请将其替换为“origin”或您决定使用的任何内容。作为预防措施,以免我的 Prime 和本地存储库变得太不正常,我将其作为我的 Prime
post-commit
挂钩:然后我可以将更改从 Hub 拉入我的本地存储库。
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: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:Then I can just pull the changes from Hub into my local repository.
您可以从更新后回显一些调试输出开始。标准输出和标准错误输出都会转发到另一端的 git send-pack,因此您可以简单地回显消息,然后您将在执行 git Push 的客户端上看到这些消息。我假设您遵循了该词的指南,使更新后脚本可执行,将存储库克隆到 Web 文件夹等。
You might start by getting post-update to echo some debugging output. Both standard output and standard error output are forwarded to git send-pack on the other end, so you can simply echo messages and you will see these on the client that you did git push. I assume you followed the guide to the word, made the post-update script executable, cloned the repo to the web folder etc.