10

I'm new to Heroku, trying to follow the "Getting Started with NodeJS tutorial" and I got stuck at the "Deploy your App" stage.

When I run "heroku create" I do not get "Git remote heroku added". I realized it was missing after trying the "git push heroku master" step and getting "fatal: Not a git repository (or any of the parent directories): .git". What did I do wrong?

7 Answers 7

19

One can go into the root of the app and run following command:

heroku git:remote -a 'app-name e.g radiant-garden-35190'

after that run following to see all the remotes associated with your app :

git remote -v

You should get a response like this :

heroku  https://git.heroku.com/radiant-garden-35190.git (fetch)
heroku  https://git.heroku.com/radiant-garden-35190.git (push)

You might not see the remote for your github if you have not committed your app yet.

8

Please do following command then enter:

git init

After that you can git push heroku master again

4
  • 1
    Thanks, I tried it and after "git push heroku master" I get a message about permission issues as follows: "Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists." What should I do?
    – sslss
    May 15, 2015 at 9:03
  • 2
    I made it! Basically I created a key with the following command: "heroku keys:add". Then "Could not find an existing public key at ~/.ssh/id_rsa.pub Would you like to generate one? [Yn] y Generating new SSH public key." After that I tried "git push heroku master" again and it worked!
    – sslss
    May 15, 2015 at 9:42
  • Marked as accepted, unfortunately I don't have the required rep to upvote you sorry.
    – sslss
    May 15, 2015 at 11:37
  • I had the same problem on win10 and running "git init" again solved my problem. Upvoting both question and answer. Thanks.
    – Alan C. S.
    Aug 31, 2016 at 23:58
3

To extend the answer from @tien-nguyen. An empty git repository should be initialized after running this:

git init

If running this right away:

git push heroku master

It will return this:

error: src refspec master does not match any.
error: failed to push some refs to 'heroku'

Very likely this is due to nothing is staged to be pushed. Add files, commit and try push again should fix the issue.

git add .
git commit -m "initial commit"
git push heroku master

This should commit and push the files into the repo.

In the case where git remote is not yet defined. Use the following:

heroku git:remote -a <name of the heroku app>
git remote -v

This should list out the remote url, should look something like this:

heroku  https://git.heroku.com/<name of the heroku app>.git (fetch)
heroku  https://git.heroku.com/<name of the heroku app>.git (push)

Now proceed with add, commit and push again.

Hope that helps!

2

Make sure you need to run this command heroku git:remote -a project_name under your project folder

1

If you want to add a custom remote name:

heroku git:remote --app my-heroku-app-name -r my-custom-remote-name
1
  • this is helpful especially I am adding second heroku remote to same git repo
    – V-SHY
    Jun 20, 2019 at 10:51
1

After running heroku create my-amazing-app, you should see a response with the web url along with the git url. Use the git url (something like git.heroku.../my-amazing-app.git) to add the remote yourself like so:

git remote add heroku git.heroku.../my-amazing-app.git

Then running git remote -v should show the new remote with heroku.

0
'heroku git:remote --app $appname'

This command does the trick to add to git remote if not added while 'heroku create'.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.