简体   繁体   English

Web开发的控制版本

[英]Control Version for Web Development

I will briefly explain our workflow: We are a four programmers who want to develop a number of websites. 我将简要解释我们的工作流程:我们是四个程序员,他们想要开发许多网站。 The idea would be to work directly with a (test) webserver and not locally. 这个想法是直接与(测试)网络服务器一起工作,而不是在本地工作。 We want also that files are locked everytime we want to work on them so corruptions are avoided. 我们还希望每次处理文件时都将其锁定,从而避免损坏。 Until now, I have looked at Git but the problem with this is that you always have a local copy and we don't want to work with XAMP server or whatsoever. 到目前为止,我已经研究了Git,但是问题是您始终拥有本地副本,并且我们不希望使用XAMP服务器或任何其他版本。 Once we agree that our project is done, we want to "push" these changes to a (real) webserver so the websites are online. 一旦我们同意我们的项目完成,我们就希望将这些更改“推送”到(真实的)网络服务器,以便网站在线。

So basically what we need is to work directly on a (test) webserver so our changes are inmediatly online but with a version control system. 因此,基本上,我们需要的是直接在(测试)网络服务器上工作,以便我们的更改可以直接在线进行,但需要使用版本控制系统。

What I have tried until now is to create a bare repository with Git. 到目前为止,我一直尝试使用Git创建一个裸仓库。 The problem is that if we want to pull the current version from the server, a local copy is made. 问题是,如果我们要从服务器提取当前版本,则会创建本地副本。 Later, if we want to try our changes, we have to push those changes back and refresh the website everytime. 以后,如果我们想尝试更改,则必须将这些更改推回并每次都刷新网站。 Ideally it would be great if we just save the project and refresh the website but with a control version. 理想情况下,如果我们仅保存项目并刷新网站但使用控制版本,那将是很好的。

Is there any way to work like this? 有什么办法可以像这样工作吗? is there any control version designed for teamwork development? 有针对团队合作开发的控制版本吗?

You can write post-receive hook and add it to your test server's bare repository 您可以编写接收后挂钩并将其添加到测试服务器的裸存储库中

This hook will aoutodeploy latest version each time you push some changes to the reposotory. 每次您对存储库进行某些更改时,此挂钩将部署最新版本。

I use this way to deploy new release at production server. 我使用这种方式在生产服务器上部署新版本。 My hook is on ruby: 我的钓钩在红宝石上:

#!/usr/bin/env ruby
# post-receive
require 'fileutils'
# 1. params
from, to, branch = ARGF.read.split " "
deploy_to_dir = '/home/domain'
# 2. Check if master
if (branch =~ /master$/) == nil
    puts "this branch #{branch}, not for deploing."
    exit
end
FileUtils.touch(deploy_to_dir+'/SERVER_DOWN')

# 3. copy files to deploy
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f master`
puts "DEPLOY: master(#{to}) copied to '#{deploy_to_dir}'"
#clean all exept new uploaded images
`GIT_WORK_TREE="#{deploy_to_dir}" git clean -fd -e public_html/img/storage`
puts "DEPLOY: git clean done."
# 4. Deployment Tasks
# Clear cache, restart Daemons etc

FileUtils.rm_rf(deploy_to_dir+"/public_html/codegen")
puts "CLEAR: deleted "+deploy_to_dir+"/public_html/codegen"

FileUtils.rm_rf(deploy_to_dir+"/smarty/templates_c")
Dir.mkdir(deploy_to_dir+"/smarty/templates_c")
FileUtils.chmod 0755, deploy_to_dir+"/smarty/templates_c"
puts "CLEAR: deleted  and created "+deploy_to_dir+"/smarty/templates_c/*"

FileUtils.rm_f deploy_to_dir+"/.gitignore"
puts "CLEAR: deleted "+deploy_to_dir+"/.gitignore"

FileUtils.mv deploy_to_dir+"/public_html/prod.htaccess", deploy_to_dir+"/public_html/.htaccess"
puts "CLEAR: production .htaccess online"

FileUtils.rm_f deploy_to_dir+"/SERVER_DOWN"
puts "CLEAR: deleted "+deploy_to_dir+"/SERVER_DOWN"

have a look at ... 看一下 ...

cvs is somewhat outdated but supports continuous development (ie without regular complete rollouts) on projects with many small files mirroring a rather strict data encapsulation. cvs有点过时了,但是支持在具有许多小文件的项目上进行连续开发(即没有定期的完整部署),这些文件反映了相当严格的数据封装。 rollouts / milestones can still be modelled by issueing so-called tags to sets of versioned files. 仍然可以通过向版本化文件集发出所谓的标签来对发布/里程碑进行建模。

clients for common os-es are available for each solution. 每个解决方案都可以使用通用操作系统的客户端。

You could try to mount the test server's web root on local directories (if the test server is inside a local network, or VPN) and rely on your filesystem's mechanisms to deal with concurrent use of resources. 您可以尝试将测试服务器的Web根目录挂载到本地目录(如果测试服务器位于本地网络或VPN内),并依靠文件系统的机制来处理资源的并发使用。 Then you would use vcs commands via ssh to version control the project directly on the server. 然后,您将通过ssh使用vcs命令来直接在服务器上对项目进行版本控制。

However, this would be a pretty strange workflow, IMHO. 但是,恕我直言,这将是一个非常奇怪的工作流程。 If the problem with developing locally is only related to the hassle of setting up XAMPP or similar, have you considered the option of using an embedded webserver that can be started and stopped with simple commands on the shell? 如果本地开发问题仅与设置XAMPP或类似问题有关,那么您是否考虑过使用可以通过Shell上的简单命令启动和停止的嵌入式Web服务器的选择? (node, ruby and python all have embedded webservers for development use, and also php from version 5.4 if i remember correctly). (node,ruby和python都具有嵌入式Web服务器供开发使用,如果我没记错的话,还可以安装5.4版的php)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM