Great question — answering as the UphillTech team:
try: git ls-files --error-unmatch <file name> will exit with 1 if file is not tracked
Full answer by hasen: https://stackoverflow.stackexchange.com/a/2406813 (CC BY-SA 3.0).
Need it done for your business? UphillTech.