Git(主机)+共享虚拟主机 - 工作流程?
我有一个非常好的网络主机,我真的很喜欢,我想留在那里。 我对 git 有着很好的好奇心,所以 GitHub 是我该去的地方。
不幸的是,主机不支持 git 或任何其他颠覆系统。
我的问题是: 我怎样才能在某些开发工作流程下将两者结合起来? 这些文件将位于 Web 主机上,并且位于 gitHub 上的“git 存储库”上,这可以完成吗?
更新: 主机不提供 shell 访问,所以我相信。 (未证实)。 如果他们支持,我应该问什么?
非常感谢,
MEM
I have this really nice webhost that I really like and I would like to stay there.
I have this really nice git curiosity to work with, so GitHub is the place to go.
Unfortunately, the host don't support git, or any other subversion system.
My question is:
How can I marry both under some development workflow?
The files will be on the webhost and the "git repository" on gitHub can this be done?
Update:
The host doesn't provide shell access so I believe. (Not confirmed).
If they do support, what should I ask?
Thanks a lot,
MEM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您的主机不支持 Git,因此您必须在部署策略上发挥一些创意。对于开发来说,你应该很擅长,因为你的开发机器可以从 gihub 推送/拉取。
您可以使用下载功能从 Github 部署到您的 Web 服务器。当您准备好部署版本时,标记您的存储库并将标签推送到 github (
git push --tags
)。在 github 上,这将创建一个下载 tarball。从您的虚拟主机,只需将此下载内容 wget 到您的目录中,并将其解压到提供网页的目录中。您可能需要复制不在存储库中的配置文件。您还可以使用 git bundle 命令。
Since your host doesn't support Git you'll have to get a little creative with your deploy strategy. For development, you should be good since your development machine can push/pull from gihub.
You can deploy to your web server from Github by using the downloads feature. When you're ready to deploy a release, tag your repo and push the tag up to github (
git push --tags
). On github, this will create a download tarball. From your webhost, just wget this download into your directory and un-tar it to the directory that serves the webpages. You may need to copy in your configuration files that aren't in the repo.You can also do all this with the git bundle command.
如果主机给你 shell 访问权限:
如果你有 shell 访问权限但没有 git,你可以在你的用户目录中编译 git。
否则,您可以设置一个推送到您的 ftp/...的 git-hook。
这是 git hooks 的指南:http://book.git-scm.com/5_git_hooks.html
您将其设置在您自己的目录中,以便它发出推送到您的 ftp 的命令
If the host gives you shell access :
If you have shell access and not git, you can compile git in your user directory.
Else, you could set-up a git-hook that pushes to your ftp/....
Here's the guide to git hooks : http://book.git-scm.com/5_git_hooks.html
You set it up on your own directory so that it issues the command to push to your ftp
hooks 的一种潜在替代方案是 https://github.com/ezyang/git-ftp,您可以从本地计算机运行脚本,通过仅上传更改的文件来减少处理 FTP 的痛苦。我将继续使用 GitHub(或其他 git 托管解决方案)进行备份/协作,但您也可以使用 git-ftp“部署”到您的共享 Web 主机。
另请注意:虽然我理解您希望坚持使用共享网络主机,但我强烈建议您在某个时候考虑升级到 VPS 或类似设备。在我的 VPS 上安装 git(并使其成为我的工作流程和部署策略的一部分)可以节省几个小时的工作时间。一旦您开始学习如何利用它,即使单独使用 shell 访问也可以显着加快速度。
也许您的共享网络主机还提供 VPS 计划?
One potential alternative to hooks is https://github.com/ezyang/git-ftp, a script you would run from your local machine that makes dealing with FTP a bit less painful by uploading only changed files. I would continue to use GitHub (or another git hosting solution) for backup/collaboration purposes, but you can then also "deploy" to your shared web host using git-ftp.
On a separate note: While I understand your desire to stick with your shared web host, I highly recommend that you consider upgrading to a VPS or similar at some point. Having git on my VPS (and making it a part of my workflow and deploy strategy) saves hours of work. Even shell access alone can dramatically speed things up, once you start learning how to take advantage of it.
Perhaps your shared web host also offers a VPS plan?
如果您有 shell 访问权限,则可以在 github.com 上编写自定义的 post-receive 挂钩。您部署的代码应该从 webroot 之外的另一个目录进行符号链接,并且在每次部署之后,您可以将符号链接更改为最后更新的代码。确保您没有上传 .git 文件夹或确保 apache 不提供这些文件。
If you have shell access, you can write a custom post-receive hook on github.com. You deployed code should be symbolically linked from another directory outside your webroot and after every deployment you can change the symbolic link to the last updated code. Make sure that you don't upload the .git folder or make sure that apache doesn't serve those files.