簡體中文 ▾ 主題 ▾ 最新版本 ▾ git-check-attr 最後更新於 2.50.0

名稱

git-check-attr - 顯示 gitattributes 資訊

概要

git check-attr [--source <tree-ish>] [-a | --all | <attr>…​] [--] <pathname>…​
git check-attr --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>…​]

描述

對於每個路徑名,此命令將列出每個屬性在該路徑名上是否被未指定已設定未設定為 git 屬性。

選項

-a, --all

列出與指定路徑關聯的所有屬性。如果使用此選項,則輸出中將不包含未指定的屬性。

--cached

僅考慮索引中的 .gitattributes,忽略工作區。

--stdin

從標準輸入(每行一個)讀取路徑名,而不是從命令列讀取。

-z

輸出格式被修改為機器可解析的。如果同時給定 --stdin,則輸入路徑將使用 NUL 字元而不是換行符分隔。

--source=<tree-ish>

對照指定的 tree-ish 檢查屬性。通常透過命名與其關聯的提交、分支或標籤來指定源樹。

--

將所有前面的引數解釋為屬性,將所有後面的引數解釋為路徑名。

如果 --stdin--all-- 均未使用,則第一個引數將被視為屬性,其餘引數被視為路徑名。

輸出

輸出格式為:<path> COLON SP <attribute> COLON SP <info> LF

除非 -z 生效,在這種情況下,NUL 用作分隔符:<path> NUL <attribute> NUL <info> NUL

<path> 是正在查詢的檔案的路徑,<attribute> 是正在查詢的屬性,而 <info> 可以是以下之一:

未指定

當該屬性未為路徑定義時。

未設定

當該屬性定義為 false 時。

已設定

當該屬性定義為 true 時。

<值>

當一個值已分配給該屬性時。

緩衝按照 git[1]GIT_FLUSH 選項的文件進行。呼叫者有責任避免因輸入緩衝區溢位或從空輸出緩衝區讀取而導致的死鎖。

示例

在示例中,使用以下 .gitattributes 檔案

*.java diff=java -crlf myAttr
NoMyAttr.java !myAttr
README caveat=unspecified
  • 列出單個屬性

    $ git check-attr diff org/example/MyClass.java
    org/example/MyClass.java: diff: java
  • 列出檔案的多個屬性

    $ git check-attr crlf diff myAttr -- org/example/MyClass.java
    org/example/MyClass.java: crlf: unset
    org/example/MyClass.java: diff: java
    org/example/MyClass.java: myAttr: set
  • 列出檔案的所有屬性

    $ git check-attr --all -- org/example/MyClass.java
    org/example/MyClass.java: diff: java
    org/example/MyClass.java: myAttr: set
  • 列出多個檔案的屬性

    $ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
    org/example/MyClass.java: myAttr: set
    org/example/NoMyAttr.java: myAttr: unspecified
  • 並非所有值都同樣明確

    $ git check-attr caveat README
    README: caveat: unspecified

另請參閱

GIT

Git[1] 套件的一部分

scroll-to-top