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).
Update
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:
Summary
First try
git initin the Heroku console (step 5 & 6), maybegitis already installed. If not:Aptfile (txt)to the root, similar to aProcfilegitsource url to theAptfileheroku run rails c`git init`in the consoleIn more detail
This was because I had not yet added an
Aptfile, so do that before deploying because it won't work without. AnAptfileis just atxt fileat the root of yourrailsapp, like aProcfile. An emptyAptfileand a successful deployment. Now we have to addgit.Install the
gitby finding the latest version and copying the link from this folder and adding it to yourAptfile. MyAptfilelooks like this:Deploy, everything should be working.
Run
heroku run rails cTry the code below again and you'll notice you get a similar error:
gitinstalled, so just make a repo:Hope this helps someone else.