使用 Git 的生产和测试服务器
我正在运行一个 PHP - MySQL 网站,并使用 Git 在我自己的服务器上设置了一个远程存储库。
我现在想要一种能够拥有生产和测试服务器的方法,以及如何能够轻松地将我的更改从开发推送到生产。并且无缝。
I am running a PHP - MySQL website, and have set up a remote repository on my own server using Git.
I now want a way to be able to have a production and a test server, and some how be able to push my changes from dev to production easily. and seamlessly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请不要使用 git 进行部署。
设置就像通常的构建过程一样。构建一个 zip,进行缩小和 lint 以及一路上的朋友......并在单独的文件中进行配置。
并使用 BuildBot 或 Hudson 或其他任何工具来实现自动化。
子孙后代将会感谢您。
Please don't use git for deployment.
Setup, like, usual build proccess. Build a zip, do minification and lint and friends along the way...and have configuration in separate file.
And use BuildBot or Hudson or whatever to automate it.
Future generations will thank You.
您可以通过在生产服务器的存储库上设置
post-update
挂钩来将部署系统与 git 结合使用。如果您不需要部署系统,而只想部署存储库中的部分文件,则可以使用 .gitattributes 文件和 git-archive 命令
post-update
钩子。You can use a deployment system with git by setting up a
post-update
hook on the production server's repository.If you don't need a deployment system, but only want some of the files in the repo deployed, you can use a
.gitattributes
file and thegit-archive
command in thepost-update
hook.如果 Git 是您想要的路线,请尝试使用两个独立的代码分支(
测试
和生产
)。在测试
上完成所有工作,确保其正常运行,然后将其合并到生产
中。将您的服务器设置为从生产
分支读取文件,您就可以开始工作了。不过,我同意 @Almad 的观点 - 如果您正在寻找更强大的部署解决方案,那么 VCS 不是最佳选择(因为部署有点违背 VCS 的目的)。
If Git is the route you want to go, try having two separate branches of the code (
test
andproduction
). Do all your work ontest
, make sure it functions properly, then merge it intoproduction
. Set your server to read files from theproduction
branch and you should be in business.I agree with @Almad, though - if you're looking for a more robust deployment solution, a VCS is not the way to go (since deployment kind of cuts against the VCS' purpose).