x@x:~/x$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# b
# main/a
nothing added to commit but untracked files present (use "git add" to track)
x@x:~/x$ git status | grep main
# main/a
Some plumbing commands do take a directory as parameter:
git ls-files -t -o -m aDirectory
would give you all files changed but not updated (not added to stage), or untracked. And that for a directory.
As written in this thread, git ls-files does not support a '--added option.
more fundamental reason is because ls-files plumbing is about the index.
Added is not about comparison between the index and the work tree.
It is between the HEAD commit and the index, and it does not belong to ls-files plumbing.
will show the status of the current directory and subdirectories.
For instance, given files (numbers) in this tree:
a/1
a/2
b/3
b/4
b/c/5
b/c/6
from subdirectory "b", git status shows new files in the whole tree:
% git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: ../a/1
# new file: ../a/2
# new file: 3
# new file: 4
# new file: c/5
# new file: c/6
#
but git status . just shows files in "b" and below.
% git status .
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: 3
# new file: 4
# new file: c/5
# new file: c/6
#
Just this subdirectory, not below
git status . shows all files below "b" recursively. To show just the files in the "b" but not below, you need to pass a list of just the files (and not directories) to git status. This is a bit fiddly, depending on your shell.
Zsh
In zsh you can select ordinary files with the "glob qualifier" (.). For example:
% git status *(.)
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4
Bash
Bash doesn't have glob qualifiers but you can use GNU find to select ordinary files and then pass them along to git status like so:
bash-3.2$ find . -type f -maxdepth 1 -exec git status {} +
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4
This uses -maxdepth which is a GNU find extension. POSIX find doesn't have -maxdepth, but you can do this:
bash-3.2$ find . -path '*/*' -prune -type f -exec git status {} +
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4