使用 Git/Github 部署
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9619440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deploying with Git/Github
提问by Burak Erdem
We are trying to setup an automated deployment environemt with Git/Github. We have 3 different environments; local, test and live. When we add a new feature on local, we first upload files to test server to test the newly created feature. If everything is OK, we than upload all files to live server. But this "uploading" process is not a perfect solution, as we sometimes forget to upload some files. Btw we also have mobile app on iPhone and Android, so mobile may be the fourth environment for us.
我们正在尝试使用 Git/Github 设置自动部署环境。我们有 3 种不同的环境;本地,测试和生活。当我们在本地添加新功能时,我们首先将文件上传到测试服务器以测试新创建的功能。如果一切正常,我们将所有文件上传到实时服务器。但是这个“上传”过程并不是一个完美的解决方案,因为我们有时会忘记上传一些文件。顺便说一句,我们在 iPhone 和 Android 上也有移动应用程序,所以移动可能是我们的第四个环境。
What we try to do is to setup an automated deployment environment. When we commit a new feature to test server, after testing this new feature we want to push it to live server.
我们尝试做的是设置一个自动化的部署环境。当我们向测试服务器提交新功能时,在测试此新功能后,我们希望将其推送到实时服务器。
There may be lots of commits on the test server but we want to push specific commits to live server. We couldn't find how to cope with 3-4 environments and not to mess codes. How will we push correct codes to live server? How will we manage our test and live servers? Are there any good recources telling how to setup different environments and deployment processes with Git/Github? Are there any articles to tell us what to do step-by-step?
测试服务器上可能有很多提交,但我们希望将特定提交推送到实时服务器。我们找不到如何处理 3-4 个环境而不是乱码。我们如何将正确的代码推送到实时服务器?我们将如何管理我们的测试和实时服务器?有没有好的资源告诉如何使用 Git/Github 设置不同的环境和部署过程?有没有文章可以告诉我们如何一步一步地做?
I've read those articles but none of them tell how to cope with local, test and live environments.
我读过这些文章,但没有一篇讲述如何处理本地、测试和实时环境。
- http://ryanflorence.com/simple-git-deployment/
- http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/
- http://toroid.org/ams/git-website-howto
- http://danielmiessler.com/study/git/
- http://ryanflorence.com/simple-git-deployment/
- http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/
- http://toroid.org/ams/git-website-howto
- http://danielmiessler.com/study/git/
EDIT 2012-03-09: I've found http://beanstalkapp.com/and http://springloops.comand they both seem very good at deployment. I'm not sure if I can trust those services but they both do exactly what I want. I will test both and share my results here to inform everyone.
编辑 2012-03-09:我找到了http://beanstalkapp.com/和http://springloops.com,它们似乎都非常擅长部署。我不确定我是否可以信任这些服务,但它们都完全符合我的要求。我将测试两者并在此处分享我的结果以通知大家。
采纳答案by Burak Erdem
I've finally found what I was looking for. http://beanstalkapp.comseems the best choice. It has automatic deployment feature and supports Git. After testing it for a week, I can say that it works very stable and fast. Thanks everyone for helping me and trying to show me the way.
我终于找到了我要找的东西。http://beanstalkapp.com似乎是最好的选择。它具有自动部署功能并支持 Git。经过一周的测试,我可以说它运行得非常稳定和快速。感谢大家帮助我并试图为我指明道路。
回答by James Andres
It sounds like you need a Continuous Integrationsystem. I have had great success with both Jenkinsand Webistrano.
听起来您需要一个持续集成系统。我在Jenkins和Webistrano上都取得了巨大的成功。
With regard to the "what files should we copy?" problem. Are you using git tags yet? If not, start using them!
关于“我们应该复制哪些文件?” 问题。你还在使用 git 标签吗?如果没有,请开始使用它们!
回答by Wes Hardaker
Whether or not git is the right choice, is a good question.
git 是否是正确的选择,这是一个很好的问题。
But if you're going to do it you should read through the gitworkflowsmanual page. Specifically, what it'll recommend and what sounds right given your problem above is that you need to put each separate "thing" to be developed into a topic/feature branch, and then merge that branch into the right tree when its done. That lets you separate out things so that you merge what is needed and stable and don't merge what isn't.
但是如果你打算这样做,你应该通读gitworkflows手册页。具体来说,它会推荐什么以及考虑到上述问题听起来正确的是,您需要将要开发的每个单独的“事物”放入主题/功能分支,然后在完成后将该分支合并到正确的树中。这使您可以将事物分开,以便合并需要且稳定的内容,而不合并不需要的内容。
回答by jesal
I ended up creating my own rudimentary deployment tool which would automatically pull down new updates from the repo - https://github.com/jesalg/SlimJim- I don't think it will fit your needs exactly but you can read how it's setup and maybe you might get some ideas out of it.
我最终创建了自己的基本部署工具,该工具会自动从 repo 中提取新更新 - https://github.com/jesalg/SlimJim- 我认为它不能完全满足您的需求,但您可以阅读它的设置方式也许你可以从中得到一些想法。
回答by managedheap84
I'm currently using git in such a way and just posted a blog article about here.
我目前正在以这种方式使用 git,并且刚刚发布了一篇关于此处的博客文章。
What I usually do is use a post-receive hook to look for commits pushed into a release branch, and when found deploys the codebase using the git archive command.
我通常做的是使用 post-receive hook 来查找推送到发布分支的提交,并在找到时使用 git archive 命令部署代码库。
This is fine for small projects, if you have multiple developers working on a project or it's a large and complex codebase I do recommend the use of a Continuous Integration system like Jenkins as suggested in a previous comment.
这对于小型项目来说很好,如果你有多个开发人员在一个项目上工作,或者它是一个庞大而复杂的代码库,我确实建议使用像 Jenkins 这样的持续集成系统,如之前的评论中所建议的那样。
Have a look at this and see if it suits your needs (includes a simple bash deployment script)
看看这个,看看它是否适合您的需求(包括一个简单的 bash 部署脚本)
Cheers
干杯