git status -> Show files that will be added (staged) in subdirectories

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 subdirectories. However, when I do git status before I stage anything, git status only shows the names of the subfolders that will be added, without being specific about which files in each subdirectory will be added (staged) if I do git add ..

Interestingly though, git status is explicit about the files that will be committed after I stage files with git add ..

Is there anyway to ask git status to be explicit about files for the files that would be staged?


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 -u is not used, the default is normal, i.e. show untracked files and directories.

The possible options are:

  • no - Show no untracked files
  • normal - Shows untracked files and directories
  • all - Also shows individual files in untracked directories.

The default can be changed using the status.showUntrackedFiles configuration variable documented in git-config(1).


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.


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).