Say I start a git repository in a folder, and I have several subdirectories in it.
I have several globbing patterns .gitignore to exclude files in the s
git ls-files -o --exclude-standard
Every path in your worktree that isn't staged (-o) and won't be ignored by git add (--exclude-standard).
You can simply use
git add --dry-run .
in the root of your repository which gives you a list of any file in any sub directory that would be added while considering .gitignore.
use git command git ls-files -o to list untracked file
instead -o use -c --cached Show cached files in the output (default)
-d --deleted Show deleted files in the output
-m --modified Show modified files in the output
How about putting a .gitignore file in your sub directories instead along the line of
# Ignore everything in this directory
*
# Except these file
!.gitignore
!file1
!file2
!file3
Try:
git status -u
or the long form:
git status --untracked-files
which will show individual files in untracked directories.
Here's the detailed description of -u option from git-status man page:
-u[<mode>]
--untracked-files[=<mode>]Show untracked files.
The mode parameter is optional (defaults to
all), and is used to specify the handling of untracked files; when-uis not used, the default isnormal, i.e. show untracked files and directories.The possible options are:
no- Show no untracked filesnormal- Shows untracked files and directoriesall- Also shows individual files in untracked directories.The default can be changed using the
status.showUntrackedFilesconfiguration variable documented in git-config(1).