Good Git deployment using branches strategy with Heroku?

What is a good deployment strategy to use with Git + Heroku (Ruby on Rails)?

Currently the way I work with my origin Git repository: All features (or 'stories') are first checked out as branches, then get merged with master and pushed to origin.

Anything pushed to origin/master triggers a script that pulls the new rails code to the staging area (simple rails webserver).

When the time comes for me to push a new production version to Heroku, should I create a new branch (called something like production_version_121), and push that somehow to Heroku?

Ideally I'd like to pick and choose which features from previous development versions I should include into the production branch... test it, and push to Heroku.

For example, I may not want all the latest code to get pushed to production. I might want feature "a" that I had worked on and feature "c" both merged into production somehow, without including experimental feature "b" which needs more debugging.

NB I'm going to try avoiding capistrano at first and get something working manually for now.

Thoughts? Best Practices?


In the Gemcutter project we simply have a production branch. Any changes that we want to see on the production site get merged into that branch, and then deployed with:

git push heroku production:master

The staging branch serves a similar purpose for the staging site (also on Heroku)


Ever since I read Vincent Driessen's A successful Git branching model, I have been hooked. My entire company (8 of us) have now standardized on this model and a few other places I've consulted with have also started using it as well.

Most everyone I've shown it to says they were doing something similar already and found it very easy to adapt.

In a nutshell, you have 2 branches that are permanent (master and develop). Most of the time you'll just be making branches off of develop and merging them back into develop. Things get a little more complex when you get into doing production releases and hotfixes, but after reading the post a couple of times, it becomes engrained.

There's even a command line tool called git-flow to help you out.


There are a variety of ways to go about this, and it really depends on your preference.

I'll give you one possible strategy off the top of my head: Given you already have an automated staging setup that uses master, I would suggest creating a 'production' branch. When you want to promote a fix/feature to production, you would just merge the topic branch into your 'production' branch.

git checkout production
git pull . my-topic-branch
(resolve any conflicts)

When you are ready to actually push that code to your production server, you should tag the branch using a unique name (probably with a timestamp). Then you simply push the production branch to Heroku.

git checkout production
git tag release-200910201249

I'd suggest creating a script or git alias to automate the tagging for timestamps, since using a consistent naming scheme is important. I use something like this:

git config alias.dtag '!git tag release-`date "+%Y%m%d%H%M"`'

That allows me to do just type git dtag when I want to tag a release with a timestamp.

You can view you tags using git tag and view them using git show release-1234 . For more information on tags, run git help tag . You may also find this Github guide on tagging helpful. I'd also recommend reading up other people's workflows (here's a nice writeup) and pick and choose what works for you.

链接地址: http://www.djcxy.com/p/48968.html

上一篇: 我如何让Leopard从命令行使用ssl

下一篇: 在Heroku中使用分支策略的良好Git部署?