Git:Web 开发的推荐设置

标签 git gitolite

两周以来,我一直在尝试在我们的办公室实现 Git。不是缺少文档,而是大量的示例、教程和 git 的各种用途让我对什么是 Web 开发的推荐设置感到困惑。

我想我已经有了一个不错的设置,但在深入研究另一个结构之前,我想咨询更有经验的人。我有以下想法:

  • 工作站推送到本地暂存服务器 (A)
  • 本地暂存服务器与 gitolite 配合使用以正确划分角色
  • Hook 会自动将对暂存服务器的任何更改推送到生产服务器 (B)

如下图所示: enter image description here

这有意义吗?我们有各种较小的 PHP 网站,没有什么很复杂的。我的疑惑是:

  • 我应该为 (B) 使用什么样的“钩子(Hook)”?
  • 我还应该在生产服务器上运行 gitolite 吗?我觉得我不应该,因为毕竟只有一个用户将东西上传到服务器(登台服务器上的钩子(Hook)),但我不确定。
  • 我的出发点是:我们在生产服务器上拥有所有网站,但尚未在登台服务器或工作站上。在初始设置时将它们“pull ”到分段和工作站的便捷方法是什么?

现在,以下问题是一些额外的想法,目前不是最重要的,但如果您碰巧知道更多,请分享您的想法:

  • 为简单起见,我更喜欢能够从工作站运行 git push 并更新登台服务器和生产服务器。但有时在上线之前只更新登台服务器并先检查那里的东西可能很有用。有没有简单的解决方案?

  • 实际上,我们不仅有一台,而且有几台不同的生产服务器。但只有一台登台服务器。有没有办法配置不同的生产服务器,以便 git 自动将它们推送到正确的服务器?

提前感谢您分享您的想法!

最佳答案

  • What kind of 'hook' should I use for (B)?

你应该使用 post-receive or post-update hooks这样做

  • Should I also run gitolite on the production server? I feel I should not, because after all it is just one user that uploads things to the server (the hook on the staging server), but I'm not sure.

由于您提到的原因,这不是强制性的,但由于 gitolite 的设置非常简单,所以不会有什么坏处

  • My starting point is: we have all websites on the Production server, and not yet on the Staging server nor the Workstations. What is a convenient way of "pulling" them down to staging and workstations, at the initial setup?

对于它们中的每一个,您都可以简单地执行这些命令

cd /path/of/project
git init
# optionally create and edit your .gitignore file before the next step
git add .
git commit

然后从您的暂存服务器运行 git clone 命令。

  • For simplicity I prefer to be able to run git push from the workstation and have both the staging server and production server updated. But sometimes it might be useful to only update the staging server and check out things over there first, before going live. Is there an easy solution?

我看不到这项任务的简单解决方案,但我不喜欢你的自动化生产部署解决方案,有些东西可能会变坏,你会破坏你的生产站点,所以我更喜欢 citizen conn多个远程解决方案。您可以使用 gitolite 和权限处理更好地管理事情。每个人都可以在临时服务器上推送,但只有少数人可以推送到生产服务器。

  • In reality we have not only one but several different production servers. But only one staging server. Is there a way of configuring different production servers so that git automatically pushes them out to the right server?

您可以将您的生产服务器地址存储在项目中的某个文本文件中,然后在您的 git Hook 中使用该文件的内容。

关于Git:Web 开发的推荐设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7072157/

相关文章:

git - 从 TFS 和 Git 复制 Visual Studio 项目而不保留源代码控制信息

git - 让 git 跟踪自动生成的文件,但忽略 diff

git - 从历史记录中删除移动的文件

linux - 我无法删除 linux 中的用户。我为 gitolite 安装创建的

linux - 外部端口/ip 上的 ssh(和 git)身份验证问题(本地 ip 工作正常)

Git pull 后 Java 项目源文件夹丢失,但 Eclipse 说它们存在

gitolite - 没有gitolite的Gitlab V5的文件级访问权限

GIT 克隆和第一个 GIT 推送问题

gitolite Hook -接收后似乎不起作用

ssh - Gitolite ssh 命令