I use git to compare strings (I've written why below). It works in development on my machine, but not on Heroku
.
`git diff $(echo "hi" | git hash-object -w --stdin) $(echo "hello" | git hash-object -w --stdin) --word-diff`
I get the following error:
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>
Does anyone know how I can get this command working on Heroku
? (btw the usage:
hint doesn't fix the problem).
Heroku support directed me to this buildpack so that I can manually install git on their servers. The solution is in my answer below.
The solution was:
First try git init
in the Heroku console (step 5 & 6), maybe git
is already installed. If not:
Aptfile (txt)
to the root, similar to a Procfile
git
source url to the Aptfile
heroku run rails c
`git init`
in the consoleremote: -----> App not compatible with buildpack: https://github.com/heroku/heroku-buildpack-apt.git
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
This was because I had not yet added an Aptfile
, so do that before deploying because it won't work without. An Aptfile
is just a txt file
at the root of your rails
app, like a Procfile
. An empty Aptfile
and a successful deployment. Now we have to add git
.
Install the git
by finding the latest version and copying the link from this folder and adding it to your Aptfile
. My Aptfile
looks like this:
https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.0.tar.gz
Deploy, everything should be working.
Run heroku run rails c
Try the code below again and you'll notice you get a similar error:
`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
installed, so just make a 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"
Hope this helps someone else.