使用Git远程维护多个可同时访问的网站版本 [英] Maintain multiple simultaneously-accessible versions of website remotely using Git

查看:105
本文介绍了使用Git远程维护多个可同时访问的网站版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置Git,这样我可以同时访问同一网站的各种版本。例如,'Sandbox'网站,'Staging'网站和'Production'网站。



我目前在Windows上安装了Git 1.7.11,并且运行Git在我的CentOs 5.5 VPS上。本地我有2个分支,'主'和'开发者'。远程我有2个分支,'master'和'dev'。



我遵循以下教程显示如何使用Git管理网站,但现在觉得我很愚蠢。我可以将文件提交到从我的本地机器到远程机器的开发分支或主分支,并且使用更新后的钩子将这些文件签出到我的Apache'htdocs'目录中。这很好,当我切换分支文件的'变化'。



然而,我想有两个版本同时访问,所以我可以运行一个网站,而客户可以查看同一网站的分期版本 然后我打算使用Git将登台/ dev合并到master中。

  GIT_WORK_TREE = / htdocs / production git checkout master -f 
GIT_WORK_TREE = / htdocs / staging git checkout dev -f


解决方案

帮助你解决Git的问题,但是在我看来,有一种方法需要更多的工作,但是作为交换的灵活性和可靠性要更高一些时,我不会喜欢web开发中的这种工作流程。

我只会标记一个裸露的公共存储库,其中所有提交都是通过推送和提取进行的(就像您使用的那个有钩子的提交),但没有任何挂钩。然后,我将在远程服务器上有两个项目目录:一个用于开发,另一个用于主控;两个都使用克隆的,非纯粹的git仓库(每个仓库都有一个.git文件夹)。因此,您的Web服务器上可能有1个裸存储库(或者它可以位于任何服务器上),也可能有2个非裸存储库。



在这种情况下,您可以将全部你想在本地,你的Web项目目录中的工作目录只会在你决定拖动时改变。如果出现与项目环境有关的错误,您可以直接在远程服务器的项目目录上进行快速更改,您可以提交修复并轻松将其恢复,这样做还有额外的好处。



使用多个远程项目目录(和url),您可以在同一台服务器上同时拥有多个项目状态。


I want to set up Git so I can have various versions of the same website accessible simultaneously. For example, a 'Sandbox' site, a 'Staging' site and a 'Production' site.

I currently have Git 1.7.11 installed on Windows, and Git running on my CentOs 5.5 VPS. Locally I have 2 branches, 'master' and 'dev'. Remotely I have 2 branches, 'master' and 'dev'.

I have followed the following tutorial showing how to manage a website using Git, but now feel I'm being rather stupid. I can commit files to either the dev branch or master branch from my local machine to the remote one, and these are checked out using a post-update hook into my Apache 'htdocs' directory. This works great, and as I switch branches the file 'changes'.

However, I want to have both versions accessible at the same time so I can run a site whilst a client can review a staging version of the same site. How do I do this? Afterward I plan to use Git to merge staging / dev into master.

Is this the best way? Checkouts in the post-update hook?

GIT_WORK_TREE=/htdocs/production git checkout master -f
GIT_WORK_TREE=/htdocs/staging git checkout dev -f

解决方案

This may not help your question regarding Git, but I would not prefer this kind of workflow in web development, when there is a way which is, in my opinion, something that requires a little more work, but in exchange is a lot more flexible and reliable.

I would just mark a bare, public repository where all commits go by push and fetch (like what you are using that has the hooks), but without any hooks. I would then have 2 project directories on the remote server: one for dev and one for master; both using cloned, non-bare git repositories (each having a .git folder). So you would have 1 bare repository on your web server (or it can be on any server) and 2 non-bare repositories.

In this case, you can push all you want locally, the working directory in your web project directories will only change when you decide to pull. This has the added benefit to being able to make quick changes directly on the remote server's project directory in case an error relating to the environment of the project comes out, which you can commit the fix and push it back easily.

And with multiple remote project directories (and urls), you can have multiple project states simultaneously on the same server.

这篇关于使用Git远程维护多个可同时访问的网站版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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