Is there a way to tell if a file is being tracked by running some git command and checking its exit code?
git
In other words: is git tracking a file?
Just my two cents:
git ls-files | grep -x relative/path
where relative/path can be easily determined by pressing tab within an auto-completion shell. Add an additional | wc -l to get a 1 or 0 output.
relative/path
tab
| wc -l