git status - >显示将在子目录中添加(暂存)的文件

Ame*_*ina 71 git version-control

假设我在一个文件夹中启动一个git存储库,其中有几个子目录.

我有几个globbing模式.gitignore来排除子目录中的文件.但是,当我git status 播放任何内容之前执行时,git status仅显示将要添加的子文件夹的名称,而不具体说明每个子目录中的哪些文件将被添加(暂存)git add ..

有趣的是,在我使用文件暂存后将提交git status的文件是明确的.git add .

反正有没有要求git status明确关于将要上演的文件的文件?

Pen*_*eng 113

尝试:

git status -u
Run Code Online (Sandbox Code Playgroud)

或长形式:

git status --untracked-files
Run Code Online (Sandbox Code Playgroud)

这将在未跟踪的目录中显示单个文件.

以下是git-status手册页-u选项的详细说明:

在此输入图像描述


小智 13

你可以简单地使用

git add --dry-run .
Run Code Online (Sandbox Code Playgroud)

在您的存储库的根目录中,它为您提供了在考虑.gitignore.


jth*_*ill 6

git ls-files -o --exclude-standard

您的工作树中的每个路径都不是staged(-o),并且不会被git add(--exclude-standard)忽略.


Adr*_*ish 0

如何将.gitignore文件放在子目录中而不是沿着

# Ignore everything in this directory
*
# Except these file
!.gitignore
!file1
!file2
!file3
Run Code Online (Sandbox Code Playgroud)