Domanda

I've had git set up and pushed to Heroku successfully for about 6 months ( on a mac using the Github app for mac).

Yesterday suddenly I can no longer push change to heroku, I got this error message:

$ git push heroku master

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

After looking around a bit it seemed it might be a problem with my key. I created a new key and added it to heroku which seemed to work:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/kat/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/kat/.ssh/id_rsa.
Your public key has been saved in /Users/kat/.ssh/id_rsa.pub.

$ heroku keys:add
Found existing public key: /Users/kat/.ssh/github_rsa.pub
Uploading SSH public key /Users/kat/.ssh/github_rsa.pub... done

But I am now getting a different error when I try to push to Heroku:

$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.

Any suggestions would be much appreciated, thanks

È stato utile?

Soluzione

It looks like the heroku remote got lost somewhere along the way. Do git remote -v in your shell and check if there is a "heroku" branch configured for push. It should look like this:

heroku git@heroku.com:myrepo.git (push).

If there isn't a remote branch set up, do heroku git:remote -a my-app-name and it should configure it. See also this article for more details.

Altri suggerimenti

I know this is an old question but I just ran into this problem and had to do quite a bit of troubleshooting to finally fix it. Thought I'd post what I did in case others are facing the same difficulty.

This is what I did to resolve the issue on mac.

Uninstall and re-install Heroku

    $ rm -rf ~/.heroku
    $ sudo rm -rf /usr/local/heroku /usr/bin/heroku

Download the latest Heroku CLI (formerly the Heroku Toolbelt) https://devcenter.heroku.com/articles/heroku-command-line

Login

    $ heroku login

You may need to check that your ssh-key is ok now.

    $ ssh-keygen -t rsa

Next, run the following to be sure to add your local ssh-key to Heroku.

    $ heroku keys:add

Log out and back in to Heroku. (note this is not standard heroku login). I'm not sure exactly why this is different but it worked for me.

    $ heroku auth:logout 

    $ heroku auth:login

Make sure a Heroku remote git is associated with the project. In my case I had to add as follows:

  `$ heroku git:remote -a <my-app-name>`

Where <my-app-name> is the name of the app already instantiated on Heroku. If you don't have one login to Heroku site and set up a new app.

I then did a standard git add and commit.

   `$ git add .`

   `$ git commit -am "fixing heroku connection issue"`

Generate a new Heroku auth token. This seems to be the crucial step.

   `$ heroku auth:token`

This should return a long auth-token made up of letters and numbers.

Try the push again but use the generated auth-token for password if prompted:

   $ git push heroku master

  Username for 'https://git.heroku.com': <your-username> or leave blank
  Password for 'https://git.heroku.com': <auth-token> 

If everything has worked it should build and push the app to Heroku.

Some of these steps might not be necessary or may have to be done in a different order. Don't be discouraged if it doesn't work first time. I had to take a couple of shots at it to get it working. Hope that helps!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top