Yes, by using git ls-files
.
git ls-files -o --exclude-standard [directory]
- -o shows other (i.e. untracked) files in the output
- --exclude-standard adds the standard Git exclusions
from .gitignore
in each directory, .git/info/exclude
and ~/.gitignore_global
.
Here is a sample git repository with 2 new untracked local files. Both of which are in a newly added untracked directory. One of the untracked files matches a pattern *.o
specified in the .gitignore
.
~/linux-stable$ ls -lR kernel/untracked-dir/
kernel/untracked-dir/:
total 8
-rw-rw-r-- 1 cvs cvs 7 Sep 2 18:46 untracked-ignored-file.o
-rw-rw-r-- 1 cvs cvs 7 Sep 2 18:46 untracked-non-ignored-file.c
Running git status
simply lists the new untracked sub-directory and not the individual files within
~/linux-stable$ git status kernel/
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
kernel/untracked-dir/
nothing added to commit but untracked files present (use "git add" to track)
Whereas using git ls-files -o --exclude-standard
, we get :
~/linux-stable$ git ls-files -o --exclude-standard
kernel/untracked-dir/untracked-non-ignored-file.c
i.e. the actual list of untracked-files (including the ones within any untracked directories).