当我尝试着将我的应用推向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帐户。


当前回答

要添加一个Heroku应用作为Git远程,你需要执行Heroku Git:remote -a yourapp。

来源:使用Git进行部署

其他回答

您可以在根目录下尝试以下操作:

//初始化项目的git,添加更改并执行提交

git init
git add .
git commit -m "first commit"

//创建heroku应用程序并推送到heroku

heroku create
git push heroku master

不知道你在这个过程中处于什么位置。你也不需要github来部署heroku,只需要git。希望这能有所帮助!

我遇到了同样的错误,而且是一个新手犯的错误:我输入的Heroku是大写的“H”,而不是小写的。

我知道这当然不是每个遇到这种错误的人的解决方案,但在我的情况下是这样的。

首先,确保你登录了heroku:

heroku login 

输入您的凭证。

在新机器上使用克隆的git repo时,经常会出现这种错误。即使您的heroku凭据已经在机器上,克隆的repo和heroku之间在本地还没有链接。要做到这一点,cd到克隆的repo的根目录并运行

heroku git:remote -a yourapp

首先,您必须安装Heroku才能识别CLI

npm install -g heroku

NPM命令需要安装node.js

你可以下载node.js: https://nodejs.org/en/download/

然后您必须登录进行身份验证

heroku login

如果你没有现存的heroku回购

heroku create

否则,如果你有一个现有的heroku回购

git remote add heroku git@heroku.com:<your app>.git

然后你可以继续推

git push heroku main

我得到了同样的错误,原来我在错误的目录。这是一个简单的错误,所以再次检查你是否在根目录下,然后运行heroku create和heroku git push master。当然,在heroku步骤之前,你必须已经做了git init,就像上面的StickMaNX回答中提到的那样。