查找 .gitignore 忽略的文件
你可以使用以下命令列出当前目录中 git 忽略的所有文件:
git status --ignored
所以,如果我们有这样的存储库结构:
.git
.gitignore
./example_1
./dir/example_2
./example_2
…和 .gitignore 文件包含:
example_2
…比命令的结果将是:
$ git status --ignored
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
.example_1
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
dir/
example_2
如果要列出目录中递归忽略的文件,则必须使用其他参数 - --untracked-files=all
结果将如下所示:
$ git status --ignored --untracked-files=all
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
example_1
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
dir/example_2
example_2