简体   繁体   中英

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. 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. 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. 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. Then you would use vcs commands via ssh to version control the project directly on the server.

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? (node, ruby and python all have embedded webservers for development use, and also php from version 5.4 if i remember correctly).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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