Managing Multiple Environments for an App


Create your servers and fix your remotes

We’ll need to create both remote environments, staging and production.Since we’ll be pushing to two applications we are using the –remote argument to make two sensibly named remotes.

First create staging:
$ heroku create --remote staging

Push code to heroku:
$ git push staging master
Migrate database:
$ heroku run rake db:migrate --remote staging
Get remote inof:
$ heroku ps --remote staging
Then production:
First create production:
$ heroku create --remote production

Push code to heroku:
$ git push production master
Migrate database:
$ heroku run rake db:migrate --remote production
Get remote inof:
$ heroku ps --remote production

Linking local branches to remote apps

This pushes my local topic branch named red-bg into remote branch master on the remote repository named production.

git config remote.[remoteName].push [localBranchName]:[remoteBranchName]

$ git config remote.production.push red-bg:master

$ git push production red-bg:master -f

Also, you can do this directly with git push:

$ git push heroku +HEAD:master
$ git push -f heroku HEAD:master

That’s it 🙂


					
Advertisements

One thought on “Managing Multiple Environments for an App

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s