Top Heroku Cli Commands I Google Everytime

There are some things that you need every day and still need to google every time 😤. In this article I’ll compile and update along the way some useful heroku commands that fall into that category

Adding an heroku app as a remote to your local git repository for deploying

If you have already created your Heroku app, you can easily add a remote to your local repository with the heroku git:remote -a appname. All you need is your Heroku app’s name:

heroku git:remote -a thawing-inlet-61413
set git remote heroku to https://git.heroku.com/thawing-inlet-61413.git

Renaming remotes

By default, the Heroku CLI names all of the Heroku remotes it creates for your app heroku. You can rename your remotes with the git remote rename command:

git remote rename heroku new-remote-name

Renaming your Heroku remote can be handy if you have multiple Heroku apps that use the same codebase (for example, the staging and production versions of an app). In this case, each Heroku app has its own remote in your local repository.

For Rails app

Running migrations

You just changed your data model and after pushing your code ( preferably first to staging ), nothing works as expected ? You just forgot to run the migrations:

heroku run rake db:migrate

Acessing a rails console

If you need to check some datas or run an action

heroku run rails console

and tada 🎉 you are logged in :)

Written on March 20, 2019