How to tell if a file is git tracked (by shell exit code)?


Is there a way to tell if a file is being tracked by running some git command and checking its exit code?

In other words: is git tracking a file?



git ls-files --error-unmatch <file name>

will exit with 1 if file is not tracked

Changing git commit message after push (given that no one pulled from remote)

Error "Fatal: Not possible to fast-forward, aborting"