Search code examples
heroku

Redeploy Heroku app without code changes


I would like to deploy a Heroku app which will be done ideally using git push -u heroku master. However this will only work if there are any pending commits to be pushed to master.

How can I redeploy the app while there is nothing to push ? I tried git push -u heroku master -f and still get the same below

Branch master set up to track remote branch master from heroku.
Everything up-to-date

PS: I also want to retain the existing app, which means I cannot make use of this answer https://stackoverflow.com/a/22043184/968442


Solution

  • Normally setting a config var causes your application to be restarted. In most situations there should be no need to redeploy after doing this.

    If you really do need to trigger a new deployment you can add a new empty commit, then push to Heroku again:

    git commit --allow-empty -m "Trigger Heroku deploy after enabling collectstatic"
    git push heroku master
    

    The new empty commit is a regular commit. It has a hash, an author, a timestamp, etc. It will have the same tree as its parent. This should cause Heroku to build your app slug again using the same code as the previous commit.

    It's a bit awkward, but it works.