Issue
I have updated my application code in GitHub, and I'd like to push those changes to my Heroku app.
Resolution
From the local repository's root directory, enter these commands:
$ git pull origin
- This pulls your repo from GitHub, assuming that
originis your GitHub remote repo. Change this depending on your local setup. This will make sure all changes committed to GitHub are in your local git repo.
$ git checkout branch-to-deploy
- This will checkout the branch you wish to deploy, for example
masterormain. You don't strictly need to do this if you are already working on this branch locally.
$ heroku git:remote -a app-name
- This will create the
herokuremote in your local repo for the app you wish to deploy to.
$ git push heroku branch-to-deploy:main
- This pushes the local branch to the Heroku app's git repository. You can change
herokudepending on what you do in step 3. You can also use a different branch here if you are not deploying frommainlocally. The last part always needs to bemainormaster, as Heroku will only start builds for pushes to themainormasterbranch.
Additional Options
-
If you use the same repo for multiple apps, you can use the
-roption on step 3 to have different remote names. For example,heroku git:remote -r heroku-dev -a heroku-dev-appwill make theheroku-devremote. You can then also add your production app to your local repo by doingheroku git:remote -r heroku-prod -a heroku-prod-app. -
To push a specific commit, specify the commit SHA in step 4. For example,
git push heroku commit-ref-sha:mainwherecommit-ref-shais the specific commit SHA.