Home > Back-end >  Can I pull down project files from a Heroku deployment?
Can I pull down project files from a Heroku deployment?

Time:04-25

So, long story short - for some reason my entire web app I've been developing has vanished from my computer and my last github push was in January (I know, terrible practice).

The app is deployed on Heroku - is there a way I can pull down the repo from heroku instead?

CodePudding user response:

Maybe.

If you've been deploying to Heroku by git push you should be able to clone from Heroku by running heroku git:clone -a APP_NAME (or just using git clone with the correct URL).

This isn't well-supported or recommended:

A Heroku app’s Git repository is intended for deployment purposes only. Cloning from this repository is not officially supported as a feature and should be attempted only as a last resort. Do not use this repository as your app’s canonical “origin” repository. Instead, use your own Git server or a version control service such as GitHub.

If you've been deploying from GitHub, this won't work. These kinds of deploys don't populate the Heroku-hosted Git repository. Though if your GitHub repo hasn't been updated since January, I suspect you're not in this boat.

If you use Heroku's Docker-based container deployment, you similarly won't be able to git clone your code. However, you should be able to fetch the container via heroku container:pull. You won't get history this way.

Finally, if none of the above options work for you, you should be able to download your application's slug by installing the heroku-slugs plugin and then using heroku slugs:download -a APP_NAME. This won't capture history, either.

In the future, I strongly recommend pushing to GitHub more frequently. Once the current outage is resolved, you should even be able to automatically deploy to Heroku when you push to GitHub.

  • Related