Good Git deployment using branches strategy with Heroku?

前端 未结 3 1367
南方客
南方客 2021-01-29 23:49

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 f

相关标签:
3条回答
  • 2021-01-30 00:12

    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)

    0 讨论(0)
  • 2021-01-30 00:12

    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.

    0 讨论(0)
  • 2021-01-30 00:12

    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.

    0 讨论(0)
提交回复
热议问题