English ▾ 主题 ▾ 最新版本 ▾ git-check-attr 最后更新于 2.43.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>…​]

描述

对于每个路径名,此命令将列出每个属性是 未指定已设置 还是 未设置 作为该路径名上的 gitattribute。

选项

-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 时。

<value>

当一个值被分配给该属性时。

缓冲发生的情况记录在 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