有多种方法可以解决此问题,这实际上取决于您的偏好。
我会给你一个可能的策略:鉴于你已经有一个使用 master 的自动登台设置,我建议创建一个“生产”分支。当您想将修复/功能提升到生产时,您只需将主题分支合并到您的“生产”分支中。
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.