当我尝试着将我的应用推向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参数缺失,那么你将得到这个错误heroku参数

[remote "heroku"]
    url = git@heroku.com:`[Your heroku app].git
    fetch = +refs/heads/*:refs/remotes/heroku/*

.git文件夹应该在你在heroku中创建的应用的本地计算机文件目录中。c:\ users \ you \你的app.git

希望这能有所帮助

其他回答

首先,您必须安装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应用作为Git远程,你需要执行Heroku Git:remote -a yourapp。

来源:使用Git进行部署

以下是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,添加更改并执行提交

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

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

heroku create
git push heroku master

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

我在这里看到了所有的答案,唯一缺少的是经过这些步骤后:

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

你应该运行下面的命令:

$ heroku git:remote -a <YourAppNameOnHeroku>

最后,运行这个:

$ git push -f heroku <NameOfBranch>:master

注意,我使用了<NameOfBranch>,因为如果你目前在master的不同分支中,它仍然会抛出错误,所以如果你在master中工作,请使用master,否则将分支的名称放在那里。