sslss
sslss

Reputation: 347

Heroku deployment, git remote not added

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?

Upvotes: 10

Views: 12642

Answers (7)

DamonWu
DamonWu

Reputation: 134

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

Upvotes: 2

Sasi Kumar M
Sasi Kumar M

Reputation: 2630

'heroku git:remote --app $appname'

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

Upvotes: 0

Hassan
Hassan

Reputation: 626

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.

Upvotes: 1

qgor
qgor

Reputation: 81

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!

Upvotes: 3

Fellow Stranger
Fellow Stranger

Reputation: 34013

If you want to add a custom remote name:

heroku git:remote --app my-heroku-app-name -r my-custom-remote-name

Upvotes: 1

Ankit kaushik
Ankit kaushik

Reputation: 1063

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.

Upvotes: 19

Tien Nguyen
Tien Nguyen

Reputation: 4358

Please do following command then enter:

git init

After that you can git push heroku master again

Upvotes: 8

Related Questions