Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…


Cannot retrieve contributors at this time

file 202 lines (132 sloc) 8.096 kb


Managing multiple Heroku accounts is not easy with the Heroku gem. This gem builds upon capabilities found in the Heroku gem by adding multi-account support so you can switch between accounts using a single command line command. In addition to the multi-account support, this gem also allows native Heroku commands enhanced with your current account settings. Once you get your feet wet with this gem, you'll soon find that you'll be using less of the heroku command and more of the hp command.


  • Multiple account management.

  • Remote database management.

  • Convenient workflow commands within the context of the current application.


  1. A UNIX-based system.

  2. Ruby 1.9.x

  3. A Heroku account.


Type the following from the command line to install:

gem install heroku_plus

You can change the default settings for this gem by creating the following file:


The contents of the file should look like this (where the default values can be changed to your liking):

:ssh_id: id_rsa
:mode: stage
:skip_switch_warnings: false
:pg_restore_options: -O -w
:current_account: ra

You can create a new account by running the following from the command line:

hp -a -c <account name>


The following is an overview of all files used by this gem (including the Heroku gem) to manage your accounts:

~/.netrc - Used by the Heroku gem, holds current account credentials. When account switching, the contents of this file will be replaced by the contents of a *.account file. 
~/.heroku/heroku_plus.yml - Settings for this gem (as mentioned above).
~/.heroku/<name>.account - Credentials for a named account (there is one for each account). When account switching, the contents of this file will replace the contents of the .netrc file.
~/.ssh/config - The SSH configuration settings for all accounts.
~/.ssh/<name> - The private SSH identity for an account (there is one for each account). Defaults to id_rsa.
~/.ssh/<name>.pub - The public SSH identity for an account (there is one for each account). Defaults to

Details of each file is described below.

Netrc (~/.netrc)

This file is automatically managed for you and looks like the following:

  password VbcudJUkMniDfRydcs8Byzwhr3BzHPqC
  password VbcudJUkMniDfRydcs8Byzwhr3BzHPqC

Heroku+ Settings (~/.heroku/heroku_plus.yml)

The global settings for Heroku+ (see details mentioned earlier).

Heroku+ Account Credentials (~/.heroku/<name>.account)

Contains account credentials for a specific account. The file data is the same as mentioned above in the .netrc file.

SSH Configuration (~/.ssh/config)

This file is automatically managed for you and looks like the following:

Host heroku.example
 IdentityFile /Users/example/.ssh/example

SSH Identity (~/.ssh/id_rsa and ~/.ssh/

You need private and public SSH identity files for each Heroku account (it is assumed you are using RSA encryption but any encryption technique will work). These files are automatically created for you when running the “hp -a -c” command, but here is how to create them manually:

ssh-keygen -t rsa -C "<email>" -f ~/.ssh/id_rsa

Project Git Configuration (~/Development/Ruby/your_project/.git/config)

This is somewhat outside the scope of documentation for this gem but I think it is important to mention. The Git configuration file, as you might know, is what configures Git for your particular project. If you have more than one branch (i.e. remote) listed within this config file you will still need to pass the –app command when issuing Heroku commands. The reason for supporting multiple branches is because you might wish to have a stage and production server where you deploy to stage before updating your production server. For example, your config file might look like this:

[remote "example-production"]
[remote "example-stage"]

This would then require you use the –app option when issuing a Heroku command. For example:

heroku restart --app example-production
heroku restart --app example-stage

Which can be done faster by switching to the mode you want to run in (i.e. production or stage) and then running the necessary command. Example:

hp -m -s production
hp -r

The above basically says that you want to switch to “production” mode (i.e. git branch) and then execute an app restart via the “hp -r” command.

Finally, while this gem alleviates the need to specify the –app command when dealing within multiple Heroku accounts, it does not help you when dealing with multiple branches within a single Heroku account. That, I leave to you.


From the command line, type: hp

hp -a, [account]       # Manage accounts.
hp -c, [console]       # Open remote console.
hp -e, [edit]          # Edit settings in default editor (as set via the $EDITOR environment variable).
hp -h, [help]          # Show this message.
hp -m, [mode]          # Manage development modes.
hp -p, [pass=COMMAND]  # Pass command to Heroku for current mode.
hp -r, [restart]       # Restart remote server.
hp -v, [version]       # Show version.
hp db                  # Manage PostgreSQL database.

For account options, type: hp help account

-c, [--create=CREATE]    # Create a new account.
-s, [--switch=SWITCH]    # Switch to existing account.
-d, [--destroy=DESTROY]  # Delete existing account.
-l, [--list]             # Show all configured accounts.
-i, [--info]             # Show current credentials and SSH identity.

For mode options, type: hp help mode

-s, [--switch=SWITCH]  # Switch development mode.
-l, [--list]           # Show development modes.

For more db options, type: hp help db

-m, [--migrate]                  # Migrate remote PostgreSQL database (for current mode) and restart server.
-b, [--backup]                   # Backup remote PostgreSQL database (for current mode).
-t, [--transfer=TRANSFER]        # Transfer remote PostgreSQL database backup for current mode to specified mode.
-i, [--import=IMPORT]            # Import latest remote PostgreSQL database (for current mode) into local database.
-I, [--import-full=IMPORT_FULL]  # Import remote PostgreSQL database (for current mode) into local database by destroying local datbase, backing up and importing remote database, and running local migrations.
-R, [--reset=RESET]              # Reset and destroy all data in remote PostgreSQL database (for current mode).


From this point forward, you can switch between accounts as follows:

  1. Change directory to the app you want to work on.

  2. Type: hp -a -s <account name>

  3. Make changes to your code.

  4. Type: git commit -a -m “Your comments.”

  5. Type: git push heroku master.

  6. Have a beer.

Upgrading from Heroku+ 4.x.x.

For those using 4.x.x and earlier, you'll find your old settings won't work. Here is how to upgrade:

  1. Delete all ~/.heroku/*.credentials files.

  2. Rename all ~/.ssh/*identity* files so that “identity” is no longer in the file name.

  3. Setup a new account for all old accounts by using the “hp -a -c” command and using the same account names as before.



To test, do the following:

  1. cd to the gem root.

  2. bundle install

  3. bundle exec rspec spec


Read CONTRIBUTING for details.


Developed by Brooke Kuhlmann at Red Alchemist


Copyright © 2010 Red Alchemist. Read the LICENSE for details.


Read the CHANGELOG for details.

Something went wrong with that request. Please try again.