Scott Watermasysk

Still Learning to Code

Even More Efficient With Heroku

I came across this blog post a couple of weeks ago, Getting efficient when working with Heroku.

The tips are definitely good and can save you some time. However, I think you can save yourself even more time and effort if you use your Git remote name instead of your Heroku application name.

Using Remotes

Most of the Heroku cli documentation uses -a or –app to specify the specific application. However, instead of using the app name, you can use -r or –remote to specify the name of a remote.

Knowing this and sticking to some specific naming conventions, you can add the following functions to back or zsh (preferred) profiles:

<p>[View the code](</p>

Naming Remotes

You can name your remotes when you create your Heroku app with the –remote parameters. You can also rename a remote at any time with the following:

git remote rename [previoususuallyheroku] production

Using the Code

Now, to run a rake command it is as simple as:

hp run rake db:migrate
hp run console

And as a side benefit, deploying now looks like this:

git push production
git push staging


One downside to this approach is you need to execute them from within your app directory. This isn’t an issue for me personally, but you will probably need to stick with the app suggestions in the in link above if you want to be able to execute commands from anywhere on your computer.