Skip to content

Instantly share code, notes, and snippets.

@sahilrajput03
Last active April 21, 2022 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahilrajput03/c44778f281e5f9856827e7c0f264ffa5 to your computer and use it in GitHub Desktop.
Save sahilrajput03/c44778f281e5f9856827e7c0f264ffa5 to your computer and use it in GitHub Desktop.
Heroku cheatsheet #herkoku #cheatsheet #herkoku cheatsheet

Heroku commands

# You can add heroku remote to any exiting repo via:
git remote add heroku <url_from_heroku_panel_for_desired_app>
git push heroku master

# To publish any other branch to heroku's master branch (only master brach in heroku's remote is published)
git push heroku my_local_branch:master

set app simple-app-11-10                    #Set variable `app` in bash, and now you can use it like that ->
# or use simple syntax:
app=simple-app-11-10

# USAGE:
heroku rollback v10 -a $app                 #Rollback to any previous version, say v10 in this command.
heroku releases -a $app                     #View all releases for an app.
heroku logs -a $app                         #View logs an app.
heroku login                                #Logs you in via browser login.
heroku create --region eu simple-app-11-10
echo "web: npm start" > Procfile             #Create Procfile (generally required).
heroku authorizations:create                 #Generate token for heroku profile via cli, yikes!.
heroku apps                                  #To know about associated apps with current account.

# run the project locally
heroku local web

# command to login the remote bash of the project you are in
heroku run bash

#IDK
heroku ps:scale web=1
heroku ps:scale web=0

Some shell scripts I made lately -

export heroku_app=simple-app-11-10

# h_createProcfile is aliased to `echo "web: npm start" > Procfile'
# ha is aliased to `heroku apps'
# hl is aliased to `heroku logs -a $heroku_app'
# hlt is aliased to `heroku logs --tail'
# # USAGE: hro some-version
# hlo is aliased to `heroku login'
# hre is aliased to `heroku releases -a $heroku_app'
# hro is aliased to `heroku rollback $@ -a $heroku_app'
#
# # LEARN: To set nodejs as buildpacks for heroku -
# heroku buildpacks:set heroku/nodejs
# # FYI: You can set this buildpack setting via 'Setings' tab in you heroku panel as well.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment