查詢 .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