当我尝试着将我的应用推向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 add .
$ git commit -m "first heroku commit"

你应该运行下面的命令:

$ heroku git:remote -a <YourAppNameOnHeroku>

最后,运行这个:

$ git push -f heroku <NameOfBranch>:master

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

其他回答

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

以下是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的文章。

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

你忘了把你的应用名字和你的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已经安装在开发人员的机器上,那么以下命令将很好地用于在heroku上部署ruby on rails应用程序。#表示注释

heroku登录 heroku创建 Heroku键:添加#将本地机器键添加到Heroku,以便 避免重复输入密码 Git push heroku master Heroku rename new-application-name #重命名应用程序 自动生成的heroku名称以外的首选名称