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?
EDIT
If you need to use git from bash there is --porcelain option to git status:
--porcelain
Give the output in a stable, easy-to-parse format for scripts. Currently this is identical to --short output, but is guaranteed not to change in the future, making it safe for scripts.
Output looks like this:
> git status --porcelain
M starthudson.sh
?? bla
Or if you do only one file at a time:
> git status --porcelain bla
?? bla
ORIGINAL
do:
git status
You will see report stating which files were updated and which ones are untracked.
You can see bla.sh is tracked and modified and newbla is not tracked:
# On branch master
# Changed but not updated:
# (use "git add ..." to update what will be committed)
#
# modified: bla.sh
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# newbla
no changes added to commit (use "git add" and/or "git commit -a")