51

Once you have uploaded your source code to Heroku, is it possible to download it from there if necessary such as in the case of a failure of your local disk?

Because of heroku's integration with git, I would assume this might be possible at least in theory.

asked Sep 4, 2009 at 0:46

6 Answers 6

44

Just go to https://dashboard.heroku.com/apps/YOUR_APP_NAME/deploy/heroku-git.

Install the Heroku Toolbelt

Download and install the Heroku Toolbelt

If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.

$ heroku login

Clone the repository

Use Git to clone YOUR_APP_NAME's source code to your local machine.

$ heroku git:clone -a YOUR_APP_NAME
$ cd YOUR_APP_NAME

Deploy your changes

Make some changes to the code you just cloned and deploy them to Heroku using Git.

$ git add .
$ git commit -am "make it better"
$ git push heroku master
answered Oct 1, 2015 at 19:29
Sign up to request clarification or add additional context in comments.

1 Comment

heroku git:clone -a YOUR_APP_NAME worked a treat. Just a reminder that the app name is what heroku knows it as (it's possible to create a heroku app without specifying an app name, in which case heroku will auto-generate one for you - so there's a chance the app name that heroku uses isn't the same as your repo name - if unsure, go to the heroku dashboard and see what it's called)
28

You are correct, you can do a "git clone", there are Heroku specific directions for local editing as well.

answered Sep 4, 2009 at 0:54

3 Comments

Recent changes are such that heroku git:clone is only useful for applications that are deployed with Heroku's hosted git service. In effect this means that applications deployed via GitHub, DropBox or "Deploy to Heroku" buttons will result in an empty repo when cloned. In that case, you'll need to download the source repository and add the heroku remote to that repo. Once you've done that you can push with git (git push heroku master) and you'll be able to clone the repo after that.
Also one thing I noticed is that I had to include the files individually. To avoid the git objects this caused a bunch of hassled. But once I copied all of the files to the folder everything worked correctly.
Thanks @conor909, can you add that as an actual answer to this question?
12

Just run the following, and you'll be good to go:

git clone [email protected]:your_app_name.git
reuben
3,37025 silver badges28 bronze badges
answered Jun 12, 2012 at 13:37

2 Comments

Permission denied (publickey) [fatal]
warning: You appear to have cloned an empty repository.
9

For the next person that comes across this and did not deploy using git, https://help.heroku.com/FZDDCBLB/how-can-i-download-my-code-from-heroku

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.

answered Jan 27, 2019 at 3:13

Comments

7

First download and install heroku CLI.

Then run this command:

heroku login

Login by using your username and password.

Then git clone by using:

heroku git:clone -a APP-NAME

**** OR ****

1) Login to heroku : https://id.heroku.com/

2) select your app.

3) Select Deploy option.

Here you will get all the details with commands for getting the source code.

galoget
7249 silver badges15 bronze badges
answered Nov 17, 2016 at 10:31

Comments

0

First, you need to install the heroku Toolbelt.

2nd, generate SSH key by the command: heroku keys:add

3rd, clone your repo: git clone [email protected]:__your_repo__.git

answered Jul 6, 2015 at 2:28

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.