|
Post by account_disabled on Apr 7, 2024 20:08:48 GMT -8
我的大部分时间都致力于让营销人员的生活更轻松的开发项目:网站、应用程序、工具、脚本等。然而,今天,我正在为网络开发人员写作,试图让他们的生活更轻松。他们的解决方案更加智能。为了简化暂存或生产环境中代码库的开发更新,我们为任何存储库创建了自动部署设置指南。 如果您想知道 Git 是什么,那么您就有点落后了,因为它已经接管了开发人员的代码版本控制工具。如果您不是开发人员,Git 作为一个记录您想要跟踪的任何文件的所有修订的工具仍然非常有用。与一些营销同事和技术专家合作开展大型内容项目? Git 可以使用同样出色的版本控制来管理每个人的草稿。这篇文章有更多关于 Git 的好信息。 为什么选择自动部署解决方案? 更好的问题可能是“为什么不呢?”如果设置正确,开发人员的工作会更轻松。部署代码时的故障点更少。它节省了大量的时间。而且,它很光滑。 您已在本地开发环境中完成对应用程序的更新,并准备好进行暂存 科威特 手机号码 和测试。您提交更改并将其推送到 Git 存储库的暂存分支。您的自动部署设置会获取这些最新更新并几乎立即将它们部署到您的临时站点上。您测试您的更新。它们看起来很坚固;您已准备好进行实时部署。返回本地开发环境,将暂存分支更新与主(或生产)分支合并。您提交并推送您的更新。同样,自动部署会处理剩下的事情。您所要做的就是(清除缓存并)测试。 有些人认为 Git 不应该用作部署工具,因为它不能正确处理权限或跟踪空目录。但是,如果使用 Apache/Nginx 用户执行的 Git 命令进行正确设置,那么对于许多应用程序来说,它似乎是一个可靠的解决方案,特别是与其他令人困惑且昂贵的部署工具相比。 营销人员:您可能想就此停止并将其发送给您的开发人员。接下来发生的事情可能没有多大意义。 您需要什么: 托管您网站的服务器。我们的示例是运行 服务器 使用 限通过 SSH 访问您的服务器户和存储库 1. 在网络服务器上 这里我们在服务器上安装并设置Git。我们还创建了一个 SSH 密钥,以便服务器可以在不使用密码的情况下与 GitHub 进行通信。 安装您已经安装了 Git,请确保它是相对较新的版本 - 如果需要,请将其升级到最新版本。,并像平常一样运行 Git 命令。事实上,这是一个很好的做法,可以让您熟悉这样做,以防您必须解决任何冲突等。 部署规则 我对 Git 自动部署解决方案的其他方法进行了更多研究,并发现了这篇不起眼的文章。它不仅更清楚地说明了为什么git pull不应将其用作部署工具,而且“部署规则”部分也准确地说明了我想要最终实现的目标。我将规则简化为我认为最适合我的需求的规则: 正在部署的分支中的所有文件都应复制到部署目录。 自上次部署以来在 Git 存储库中删除的文件应从部署目录中删除。 遵循规则一和规则二时,应忽略上次部署后对部署目录中跟踪文件的任何更改。
|
|