当我尝试着将我的应用推向Heroku时,我得到了这样的回应:

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

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

我尝试过“heroku keys:add”,但仍然得到相同的结果。 我已经有一个ssh密钥为我的GitHub帐户。


当前回答

我的问题是我使用git(而不是heroku git)来克隆应用程序。然后我必须:

git remote add heroku git@heroku.com:MyApp.git

记得将MyApp更改为您的应用程序名称。

然后我可以继续:

git push heroku master

其他回答

遵循以下步骤:

$ heroku login

创建一个新的Git存储库 在新目录或现有目录中初始化git存储库

$ cd my-project/
$ git init
$ heroku git:remote -a appname

部署应用程序 将代码提交到存储库,并使用Git将其部署到Heroku。

$ git add . 
$ git commit -am "make it better"
$ git push heroku master

现有Git存储库 对于现有的存储库,只需添加heroku远程

$ heroku git:remote -a appname

如果这个错误弹出,这是因为没有名为Heroku的远程。当你创建Heroku时,如果git远程不存在,我们会自动创建一个(假设你在一个git repo中)。要查看遥控器,输入:

“git remote -v”。#对于一个名为“appname”的应用程序,你将看到以下内容:

$ git remote -v
heroku git@heroku.com:appname.git (fetch)
heroku git@heroku.com:appname.git (push)

如果你看到你的应用程序的遥控器,你可以“git push master”并替换为实际的遥控器名称。

如果没有,你可以用下面的命令添加遥控器:

git remote add heroku git@heroku.com:appname.git

如果你已经添加了一个名为Heroku的遥控器,你可能会得到这样的错误:

fatal: remote heroku already exists.

所以,然后删除现有的远程,并用上面的命令再次添加它:

git remote rm heroku

希望这对你有所帮助……

你忘了把你的应用名字和你的heroku链接起来。这是一个很常见的错误。 如果你的应用还没有创建,那么使用:

heroku create (optional app name)

其他:

git add .
git commit -m "heroku commit"

heroku git:remote -a YOUR_APP_NAME

git push heroku master

以下是Heroku官方文章:

初始化GIT

$ cd myapp
$ git init

$ git add .
$ git commit -m "my first commit"

然后创建(初始化)heroku应用程序:

$ heroku create YourAppName

最后添加git远程:

$ heroku git:remote -a YourAppName

现在你可以安全地部署你的应用程序:

$ git push heroku master

您应该等待一段时间,看看在部署时控制台是否没有任何错误/中断。详情请看heroku的文章。

在我的情况下,我已经登录了,我只是执行了git push。