0

我使用 git 来比较字符串(我在下面写了原因)。它适用于我的机器上的开发,但不适用于Heroku.

`git diff $(echo "hi" | git hash-object -w --stdin) $(echo  "hello" | git hash-object -w --stdin)  --word-diff`

我收到以下错误:

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Not a git repository
To compare two paths outside a working tree:
usage: git diff [--no-index] <path> <path>

有谁知道我怎样才能让这个命令起作用Heroku?(顺便说一句,usage:提示不能解决问题)。

更新

Heroku 支持将我引导到这个buildpack,以便我可以在他们的服务器上手动安装 git。解决方案在我下面的答案中。

4

1 回答 1

3

解决方案是:

概括

git init首先在 Heroku 控制台中尝试(第 5 步和第 6 步),可能git已经安装了。如果不:

  1. 安装此构建包
  2. 将 a 添加Aptfile (txt)到根,类似于 aProcfile
  3. 将最新的git 源 URL添加到Aptfile
  4. 部署
  5. heroku run rails c
  6. `git init`在控制台中

更详细

  1. Heroku 将我引导到这个buildpack。易于安装。但最初给了我这个错误,没有太多解释:
remote: -----> App not compatible with buildpack: https://github.com/heroku/heroku-buildpack-apt.git
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
  1. 这是因为我还没有添加Aptfile,所以在部署之前这样做,因为没有它就无法工作。AnAptfile只是您应用程序txt file的根目录中的a,例如. 一个空的和成功的部署。现在我们必须添加.railsProcfileAptfilegit

  2. 通过git找到最新版本并从此文件夹复制链接并将其添加到您的Aptfile. 我的Aptfile样子是这样的:

https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.0.tar.gz
  1. 部署,一切都应该正常工作。

  2. heroku run rails c

  3. 再次尝试下面的代码,你会发现你得到了一个类似的错误:

`git diff $(echo "hi" | git hash-object -w --stdin) $(echo  "hello" | git hash-object -w --stdin)  --word-diff`
=> fatal: not a git repository (or any parent up to mount point /)
=> Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
=> fatal: not a git repository (or any parent up to mount point /)
=> Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
=> Not a git repository
=> To compare two paths outside a working tree:
=> usage: git diff [--no-index] <path> <path>
  1. 但是我们现在已经git安装了,所以只需创建一个 repo:
`git init`
=> "Initialized empty Git repository in /app/.git/\n"
  1. 成功:
`git diff $(echo "hi" | git hash-object -w --stdin) $(echo  "hello" | git hash-object -w --stdin)  --word-diff`
=> "diff --git a/45b983be36b73c0788dc9cbcb76cbb80fc7bb057 b/ce013625030ba8dba906f756967f9e9ca394464a\nindex 45b983b..ce01362 100644\n--- a/45b983be36b73c0788dc9cbcb76cbb80fc7bb057\n+++ b/ce013625030ba8dba906f756967f9e9ca394464a\n@@ -1 +1 @@\n[-hi-]{+hello+}\n"

希望这对其他人有帮助。

于 2020-02-03T11:20:32.917 回答