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?
try:
git ls-files --error-unmatch <file name>
will exit with 1 if file is not tracked
using git log
will give info about this. If the file is tracked in git the command shows some results(logs). Else it is empty.
For example if the file is git tracked,
root@user-ubuntu:~/project-repo-directory# git log src/../somefile.js
commit ad9180b772d5c64dcd79a6cbb9487bd2ef08cbfc
Author: User <someone@somedomain.com>
Date: Mon Feb 20 07:45:04 2017 -0600
fix eslint indentation errors
....
....
If the file is not git tracked,
root@user-ubuntu:~/project-repo-directory# git log src/../somefile.js
root@user-ubuntu:~/project-repo-directory#