【问题标题】:heroku fork + heroku git:clone = New app works but empty repositoryheroku fork + heroku git:clone = 新应用程序有效,但存储库为空
【发布时间】:2015-07-24 20:19:36
【问题描述】:

我有一个名为 app1 的 Heroku Rails 应用程序,它有源代码并且可以运行。
我想创建一个受它启发但又不同的新应用程序,使用不同的代码和 URL,所以我运行了:

$ heroku fork --from app1 --to app2
$ [...]
$ Fork complete. View it at https://app1.herokuapp.com/

我检查了那个 URL:克隆的应用程序可以正常工作。
现在让我们将它克隆到我的本地计算机,以便我可以修改它:

$ heroku git:clone -a app2
Cloning into 'app2'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ cd app2/
$ ls

问题:此文件夹中没有任何内容。存储库是空的!
这怎么可能?应用程序是否可以在没有代码的情况下运行?
是否有错误的命令来创建代码的本地副本?

【问题讨论】:

  • @JaimeAgudo:你的意思是那个问题是我的问题的重复吗?
  • 可能,但我的意思是分享解决方案,这可能与我在官方 heroku 帮助@Nicolas_Raoul 上找到的唯一相关解决方案相同

标签: git heroku heroku-toolbelt


【解决方案1】:

是的,请参阅 the documentation,它指出 Git 存储库将为空。

该应用正在运行,因为它具有相同的slug

一般来说,我建议不要将 Heroku 视为源代码存储库,而是将其放在另一个地方(比如 GitHub)。

【讨论】:

    【解决方案2】:

    Jon 的回答解释了为什么存储库是空的。
    以下是解决“问题”的方法:

    $ cat app1/.git/config
    

    记下origin段落中url的值。
    它可能看起来像git@heroku.com:app1.git
    然后运行:

    $ cd app2
    $ git pull git@heroku.com:app1.git
    $ git push
    

    这将检索源代码(忽略 Your branch is based on 'heroku/master', but the upstream is gone. 消息)并将克隆的 slug 替换为基于此源代码构建的代码。

    【讨论】:

    • 这应该是遵循 SO 准则的公认答案
    猜你喜欢
    • 2013-09-16
    • 2012-11-28
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 2020-11-06
    • 2012-09-24
    • 1970-01-01
    • 2017-01-03
    相关资源
    最近更新 更多