我刚从大学毕业,开始在一个三人开发团队工作。代码库目前不在任何版本控制系统下。我们的代码库采用经典ASP,Adobe Contribute集成在一起,允许内容创建者更新自己的内容。现在,我们通过将Web服务器的驱动器映射到我们的工作站,直接在生产网站上进行开发。我坚信我们应该将某种形式的版本控制集成到我们的工作流程中,并停止在生产Web服务器上开发以支持本地开发的实践。
我想工作流程的工作原理如下:
我的思路可能不正确,但我正在寻找那些有更多经验的人的推荐。
答案 0 :(得分:1)
由于您已经拥有Web服务器,因此您可以在您自己的服务器上设置git服务器(远程仓库)。这样可以更容易地为远程仓库使用服务器端挂钩。
用于版本控制实时网站的工作流程,如下所示:
开发远程回购的本地副本 - >进行更改 - >提交 - >推动开发远程回购 - >如果您准备将更改部署到网站 - >将更改推送到生产远程仓库。
先决条件:您自己服务器上的两个远程仓库。
设置devleop远程回购:
# go to a directory, create an empty folder
mkdir develop
cd develop
git init --bare
# assume the URL for the develop repo is www.site/develop
设置生产服务器:
# go to a directory, create an empty folder
mkdir production
cd production
git init --bare
# assume the URL for the develop repo is www.site/production
在本地计算机中,克隆开发存储库并在git中添加要进行版本控制的文件:
git clone www.site/develop
cd develop
# add all the files for the website which you want to manage in git
git add .
git commit -m 'message'
git push origin master
如果您已经在生产远程仓库中推送文件,则可以使用以下命令:
git remote add prodcuton www.site/production -f
git push production master
如果更改需要在每次推送更改后立即推送生产远程仓库以开发回购,您可以在开发仓库 .git / hooks 中使用后接收挂钩 strong>文件夹:
#!/bin/bash
git --work-tree=/path/to/develop --git-dir=/path/to/production checkout -f
您还可以参考Simple automated GIT Deployment using Hooks和Using Git to Manage a Live Web Site。