How can I download my code from Heroku?

Issue

You need to recover your application source code from Heroku.

Resolution

Cloning the git repository

If you have deployed your application via our git push heroku master method, or via Heroku Pipelines, you can download the latest revision from our git servers with:

heroku git:clone -a APP-NAME

This will clone the git repository to your machine with the latest code. Please note, this will only include branches that you have pushed to Heroku, which in most cases will only be the master branch.

Downloading the application slug

If you have not used git to deploy your application, or using heroku git:clone has only created an empty repository, you can download the slug that was build when you application was last deployed. First, install the heroku-slugs CLI plugin with heroku plugins:install heroku-slugs, then run:

heroku slugs:download -a APP_NAME

This will download and compress your slug into a directory with the same name as your application.