我已经安装了git并成功推送到Heroku大约6个月(使用Mac的Github应用程序在Mac上)。
昨天我突然无法再将更改推送到heroku,我收到了以下错误消息:
$ 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.
看了一下后,我的钥匙似乎有问题。 我创建了一个新密钥并将其添加到heroku中,这似乎有用:
$ 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
但是当我尝试推送到Heroku时,我现在遇到了一个不同的错误:
$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
非常感谢任何建议,谢谢
答案 0 :(得分:1)
看起来heroku遥控器在途中丢失了。在shell中执行git remote -v
并检查是否配置了“heroku”分支以进行推送。它应该是这样的:
heroku git@heroku.com:myrepo.git (push)
。
如果没有设置远程分支,请执行heroku git:remote -a my-app-name
并配置它。有关详细信息,另请参阅this article。
答案 1 :(得分:0)
我知道这是一个老问题,但我遇到了这个问题,不得不进行相当多的故障排除才能最终修复它。以为我会发布我所做的事情以防其他人面临同样的困难。
这就是我在mac上解决问题的方法。
卸载并重新安装Heroku
$ rm -rf ~/.heroku
$ sudo rm -rf /usr/local/heroku /usr/bin/heroku
下载最新的Heroku CLI(以前的Heroku Toolbelt) https://devcenter.heroku.com/articles/heroku-command-line
登录
$ heroku login
您可能需要检查您的ssh-key现在是否正常。
$ ssh-keygen -t rsa
接下来,运行以下命令以确保将本地ssh-key添加到Heroku。
$ heroku keys:add
退出并重新登录Heroku。 (注意这不是标准的heroku登录)。我不确定为什么这会有所不同,但它对我有用。
$ heroku auth:logout
$ heroku auth:login
确保Heroku远程git与项目相关联。在我的情况下,我必须添加如下:
`$ heroku git:remote -a <my-app-name>`
其中<my-app-name>
是已在Heroku上实例化的应用程序的名称。如果您没有登录Heroku网站并设置新的应用程序。
然后我做了一个标准的git add和commit。
`$ git add .`
`$ git commit -am "fixing heroku connection issue"`
生成新的Heroku身份验证令牌。这似乎是至关重要的一步。
`$ heroku auth:token`
这应该返回一个由字母和数字组成的长auth-token
。
再次尝试推送,但如果出现提示,请使用生成的auth-token
密码:
$ git push heroku master
Username for 'https://git.heroku.com': <your-username> or leave blank
Password for 'https://git.heroku.com': <auth-token>
如果一切正常,它应该构建并将应用程序推送到Heroku。
其中一些步骤可能不是必需的,或者可能必须以不同的顺序完成。如果它不是第一次工作,请不要气馁。我不得不对它进行几次拍摄以使其正常工作。希望有所帮助!