【问题标题】:Heroku: 'Push rejected, repository is empty' on Cloud9 IDEHeroku:Cloud9 IDE 上的“推送被拒绝,存储库为空”
【发布时间】:2013-07-25 17:20:28
【问题描述】:

我正在使用 Cloud9 IDE,我刚刚尝试部署到 Heroku,但出现此错误:

[1/5] Verifying preconditions...
[2/5] Updating repository...
[3/5] Pushing to Heroku...
1:: Warning: Permanently added the RSA host key for IP address '50.19.85.154' to the list of known hosts.
!     Push rejected, repository is empty
To git@heroku.com:anthro-site.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:anthro-site.git'

我环顾四周,发现这里有几个类似的问题,例如this one,但不幸的是,该问题的答案需要我安装软件,我认为我不允许在 Cloud9 上这样做.我似乎无法访问heroku 命令,所以它一定不是为我安装的。我该如何进行?

【问题讨论】:

  • 您确定您之前已经将您的代码推送到 Cloud9 吗? Cloud9 上的 repo 似乎是空的,它无法推送到 heroku,因为没有什么可推送的。要么那个要么提交是空的。
  • @ChristianStewart “将 [我的] 代码推送到 Cloud9” 是什么意思?我在 Cloud9 上编写了我的代码。为什么我必须把它推到除了 Heroku 之外的任何地方?
  • @ChristianStewart 我确实想知道我是否需要将我的代码放在我的origin/master 上,但出于组织原因,我不想这样做。你认为这可能是我的问题吗?
  • 抱歉,不太确定 Cloud9 的工作原理。你有没有做出任何承诺?是的,代码应该在 master 分支中(这是 Heroku 寻找的分支)。
  • @ChristianStewart 哦。它是一个在线 IDE,因此您可以在那里编写/运行代码,并可选择推送到 GitHub、BitBucket 或 Heroku 等其他地方。我做了很多提交并成功地将它们推送到 GitHub。我无法想象为什么 Heroku 认为我的存储库是空的。

标签: heroku cloud9-ide


【解决方案1】:

显然您可以在 Cloud9 上安装 Heroku 客户端,如 here 所述:

要部署到 Heroku,请输入以下命令:

wget http://assets.heroku.com/heroku-client/heroku-client.tgz
tar xzfv heroku-client.tgz
cd heroku-client/bin
PATH=$PATH:$PWD

现在,您可以对项目使用 heroku 命令,如 Heroku 文档中所述。

但这不是我的问题。似乎为了推送到 heroku,你必须在你的 master 分支上。我的步骤如下:

$ git checkout master
$ git merge dev # that's the branch I was working on
                # if you don't merge, master will not have whatever
                # commits you've made to the branch you were on.
$ git push --set-upstream heroku master

之后我等待 Heroku 完成安装我的应用程序,现在我可以访问它了。

【讨论】:

    【解决方案2】:

    https://devcenter.heroku.com/articles/git#deploying-code

    推送到 Heroku 的除 master 之外的分支将被忽略 命令。如果您在本地的另一个分支机构工作,您可以 在推送之前合并到主控,或指定您想要 将本地分支推送到远程 master。推送除 大师,使用这个语法:

    $ git push heroku yourbranch:master

    它对我有用。

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 2016-02-21
      • 2014-12-12
      • 2020-08-29
      • 1970-01-01
      • 2019-06-09
      • 2017-01-09
      • 2021-09-22
      相关资源
      最近更新 更多