运行 Heroku 上的 git shell 命令
Running a git shell command on Heroku
我使用 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。解决方案在我下面的回答中。
解决方案是:
总结
首先在 Heroku 控制台中尝试 git init
(第 5 步和第 6 步),也许 git
已经安装。如果不是:
- 安装这个 buildpack
- 向根添加一个
Aptfile (txt)
,类似于Procfile
- 将最新的
git
source url 添加到 Aptfile
- 部署
heroku run rails c
`git init`
在控制台
更详细
- 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
这是因为我还没有添加 Aptfile
,所以在部署之前添加,因为没有它就无法工作。 Aptfile
只是 rails
应用程序根目录中的 txt file
,就像 Procfile
。空 Aptfile
且部署成功。现在我们必须添加 git
.
通过查找最新版本并从 this folder 复制 link 并将其添加到您的 Aptfile
来安装 git
。我的 Aptfile
看起来像这样:
https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.0.tar.gz
部署,一切正常。
运行 heroku run rails c
再次尝试下面的代码,您会发现您遇到了类似的错误:
`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>
- 但我们现在已经安装了
git
,所以只需制作一个 repo:
`git init`
=> "Initialized empty Git repository in /app/.git/\n"
- 成功:
`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"
希望这对其他人有帮助。
我使用 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。解决方案在我下面的回答中。
解决方案是:
总结
首先在 Heroku 控制台中尝试 git init
(第 5 步和第 6 步),也许 git
已经安装。如果不是:
- 安装这个 buildpack
- 向根添加一个
Aptfile (txt)
,类似于Procfile
- 将最新的
git
source url 添加到Aptfile
- 部署
heroku run rails c
`git init`
在控制台
更详细
- 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
这是因为我还没有添加
Aptfile
,所以在部署之前添加,因为没有它就无法工作。Aptfile
只是rails
应用程序根目录中的txt file
,就像Procfile
。空Aptfile
且部署成功。现在我们必须添加git
.通过查找最新版本并从 this folder 复制 link 并将其添加到您的
Aptfile
来安装git
。我的Aptfile
看起来像这样:
https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.0.tar.gz
部署,一切正常。
运行
heroku run rails c
再次尝试下面的代码,您会发现您遇到了类似的错误:
`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>
- 但我们现在已经安装了
git
,所以只需制作一个 repo:
`git init`
=> "Initialized empty Git repository in /app/.git/\n"
- 成功:
`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"
希望这对其他人有帮助。