# git-check-ignore
> 原文: [https://git-scm.com/docs/git-check-ignore](https://git-scm.com/docs/git-check-ignore)
## 名稱
git-check-ignore - 調試gitignore / exclude文件
## 概要
```
git check-ignore [<options>] <pathname>…?
git check-ignore [<options>] --stdin
```
## 描述
對于通過命令行或通過`--stdin`從文件給出的每個路徑名,檢查文件是否被.gitignore(或排除機制的其他輸入文件)排除,并輸出路徑(如果它被排除)。
默認情況下,跟蹤文件根本不顯示,因為它們不受排除規則的約束;但請參閱'--no-index'。
## OPTIONS
```
-q, --quiet
```
不要輸出任何內容,只需設置退出狀態即可。這僅對單個路徑名有效。
```
-v, --verbose
```
還輸出有關每個給定路徑名的匹配模式(如果有)的詳細信息。有關排除源內和排除源之間的優先級規則,請參閱 [gitignore [5]](https://git-scm.com/docs/gitignore) 。
```
--stdin
```
從標準輸入讀取路徑名,每行一個,而不是命令行。
```
-z
```
輸出格式被修改為可機器解析(見下文)。如果還給出`--stdin`,則輸入路徑用NUL字符而不是換行符分隔。
```
-n, --non-matching
```
顯示與任何模式都不匹配的給定路徑。這僅在啟用`--verbose`時才有意義,否則將無法區分匹配模式的路徑和不匹配模式的路徑。
```
--no-index
```
在進行檢查時不要查看索引。這可以用于調試由例如跟蹤路徑的原因。 `git add .`并且未被用戶預期的規則忽略,或者在開發包含否定的模式以匹配先前使用`git add -f`添加的路徑時。
## OUTPUT
默認情況下,將輸出與忽略模式匹配的任何給定路徑名,每行一個。如果沒有模式匹配給定路徑,則不會為該路徑輸出任何內容;這意味著路徑不會被忽略。
如果指定了`--verbose`,則輸出是以下形式的一系列行:
<信源> <結腸癌和GT; < LINENUM> <結腸癌和GT; <模式> < HT> <路徑名>
<路徑名>是要查詢的文件的路徑,< pattern>是匹配模式,< source>是模式的源文件,< linenum>是該源中模式的行號。如果模式包含`!`前綴或`/`后綴,則它將保留在輸出中。 <信源>在引用`core.excludesFile`配置的文件時,或者在引用`.git/info/exclude`或每個目錄的排除文件時相對于存儲庫根目錄時,它將是絕對路徑。
如果指定了`-z`,則輸出中的路徑名由空字符分隔;如果還指定了`--verbose`,則還使用空字符代替冒號和硬標簽:
<信源> < NULL> < LINENUM> < NULL> <模式> < NULL> <路徑名> < NULL>
如果指定了`-n`或`--non-matching`,則還將輸出不匹配的路徑名,在這種情況下,每個輸出記錄中的所有字段除了< pathname>將是空的。這在非交互式運行時非常有用,因此可以將文件遞增地流式傳輸到長時間運行的檢查忽略過程的STDIN,并且對于每個文件,STDOUT將指示該文件是否與模式匹配。 (如果沒有這個選項,就不可能判斷給定文件的輸出是否缺少意味著它是否與任何模式不匹配,或者輸出是否尚未生成。)
緩沖發生在 [git [1]](https://git-scm.com/docs/git) 的`GIT_FLUSH`選項中。調用者負責避免因輸入緩沖區過滿或從空輸出緩沖區讀取而導致的死鎖。
## 退出狀態
```
0
```
忽略一個或多個提供的路徑。
```
1
```
沒有提供的路徑被忽略。
```
128
```
遇到致命錯誤。
## 也可以看看
[gitignore [5]](https://git-scm.com/docs/gitignore) [git-config [1]](https://git-scm.com/docs/git-config) [git-ls-files [1]](https://git-scm.com/docs/git-ls-files)
## GIT
部分 [git [1]](https://git-scm.com/docs/git) 套件
- git
- git-config
- git-help
- git-init
- git-clone
- git-add
- git-status
- git-diff
- git-commit
- git-reset
- git-rm
- git-mv
- git-branch
- git-checkout
- git-merge
- git-mergetool
- git-log
- git-stash
- git-tag
- git-worktree
- git-fetch
- git-pull
- git-push
- git-remote
- git-submodule
- git-show
- git-log
- git-shortlog
- git-describe
- git-apply
- git-cherry-pick
- git-rebase
- git-revert
- git-bisect
- git-blame
- git-grep
- gitattributes
- giteveryday
- gitglossary
- githooks
- gitignore
- gitmodules
- gitrevisions
- gittutorial
- gitworkflows
- git-am
- git-format-patch
- git-send-email
- git-request-pull
- git-svn
- git-fast-import
- git-clean
- git-gc
- git-fsck
- git-reflog
- git-filter-branch
- git-instaweb
- git-archive
- git-bundle
- git-daemon
- git-update-server-info
- git-cat-file
- git-check-ignore
- git-checkout-index
- git-commit-tree
- git-count-objects
- git-diff-index
- git-for-each-ref
- git-hash-object
- git-ls-files
- git-merge-base
- git-read-tree
- git-rev-list
- git-rev-parse
- git-show-ref
- git-symbolic-ref
- git-update-index
- git-update-ref
- git-verify-pack
- git-write-tree