简体   繁体   English

使用单一服务器进行网站开发的Git

[英]Git for website development with single server

I have a website built on php and MySQL and trying to finally become more organised using git for making a distinction between code that is live and code that is still in test. 我有一个基于phpMySQL构建的网站,并试图最终使用git变得更有条理,以便区分实时代码和仍在测试中的代码。 I am the only developer working on the site 我是该网站上唯一的开发人员

I cannot afford having a production and test server. 我买不起生产和测试服务器。 So on the same server I made separate folders, one which is live /www/live/ and the other that is in development /www/dev/ . 因此,在同一台服务器上,我创建了单独的文件夹,一个文件夹为live /www/live/ ,另一个位于开发中/www/dev/

The development part of the site /www/dev/ is linked to a sub-domain dev.mydomain.com 网站/www/dev/的开发部分链接到子域dev.mydomain.com

Problem 1: I wish to setup git in such a way that my commits go to /www/dev/ and my pushes go live to /www/live . 问题1:我希望以一种方式设置git ,使我的提交进入/www/dev/而我的推送进入/www/live Is it reasonable to do it this way? 这样做是否合理?

Problem 2: There are two places in the /www/dev code where links to the MySQL development database and folders are hard-coded. 问题2: /www/dev代码中有两个地方是对MySQL开发数据库和文件夹的链接进行硬编码的地方。 Commits would work fine, but then pushes would change the live code to now point to development databases and folders. 提交可以正常工作,但是推送将更改实时代码,使其现在指向开发数据库和文件夹。 Is there a neat way of managing this? 有没有一种整齐的方法来管理这个?

  1. No - that's what git branches are for. 不-那就是git分支的用途。 Create a new branch called develop for all of your dev stuff and push commits to that which you would pull down from /www/dev . 为您所有的开发人员创建一个新的分支,称为develop,然后将提交推送到从/www/dev下拉的分支。 When ready to go live, merge the develop branch into master and pull master down on /www/live 准备上线时,将develop分支合并到master并在/www/live上拉下master

  2. Either git ignore the config files or better yet define the environment based on URL, directory path or an environment variable. git要么忽略配置文件,要么更好地根据URL,目录路径或环境变量定义环境。

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

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