版本控制工作流推荐

Version Control Workflow Recommendation

我刚大学毕业,开始在一个三人开发团队工作。代码库目前不在任何版本控制系统下。我们的代码库是经典 ASP 并且集成了 Adob​​e Contribute 以允许内容创建者更新他们自己的内容。现在,我们通过将 Web 服务器的驱动器映射到我们的工作站来直接在生产网站上进行开发。我坚信我们应该将某种形式的版本控制集成到我们的工作流程中,并停止在生产 Web 服务器上进行开发以支持本地开发的做法。

我想象工作流程如下所示:

  1. 每天从网络服务器获取任何更改并更新本地文件
  2. 将获取的更改提交到个人版本控制系统(例如Github)或分支
  3. 对本地副本进行一些更改
  4. 将我所做的更改提交到个人版本控制系统(例如Github)或分支
  5. 将修改后的文件推送到网络服务器并处理任何冲突

我的思路可能不正确,希望有经验的大佬指点一下。

由于您已经有了网络服务器,您可以在自己的服务器上设置git服务器(远程回购)。这将使远程仓库使用服务器端挂钩变得更加容易。

工作流程 版本控制实时网站如下:

处理开发远程仓库的本地副本 -> 进行更改 -> 提交 -> 推送到开发远程仓库 -> 如果你准备好将更改部署到网站 -> 将更改推送到生产远程仓库.

先决条件: 在您自己的服务器上有两个远程仓库。

设置开发远程仓库:

# 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

如果变更每次推送到develop repo后需要立即推送生产远程repo,可以在develop repo中使用post-receive hook .git/hooks 文件夹:

#!/bin/bash
git --work-tree=/path/to/develop --git-dir=/path/to/production checkout -f

也可以参考Simple automated GIT Deployment using Hooks and Using Git to Manage a Live Web Site.