I'm trying to run git diff --no-index --numstat <string> <string>
on Linux (Debian Docker container), but I'm failing in finding a way to achieve this. In essence I want to pass the files' contents as strings instead of their file paths. The goal is to retrieve the stats from the --numstat
flag.
This command should be executable outside of a git
repository/directory and on Linux. So far, I've found two solutions which lack the former requirements:
git diff --no-index --numstat /dev/fd/3 /dev/fd/4 3<<<$(echo "<string>") 4<<<$(echo "<string>")
: This works on MacOS, but fails to work on Linux.git diff --numstat $(echo <string> | git hash-object -w --stdin) $(echo <string> | git hash-object -w --stdin)
: which only works insidegit
repositories (got this partial solution from here)
Certainly there must be a way to achieve this, either via some git
command or other bash
concepts I'm unaware of. Any help would be great.
Thanks!