简体中文 ▾
Localized versions of git-check-attr manual
Topics ▾
Email
Latest version
▾
git-check-attr last updated in 2.52.0
Changes in the git-check-attr manual
Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.52.0 2025年11月17日
- 2.50.1 → 2.51.2 no changes
- 2.50.0 2025年06月16日
- 2.43.1 → 2.49.1 no changes
- 2.43.0 2023年11月20日
- 2.40.1 → 2.42.4 no changes
- 2.40.0 2023年03月12日
- 2.25.1 → 2.39.5 no changes
- 2.25.0 2020年01月13日
- 2.18.1 → 2.24.4 no changes
- 2.18.0 2018年06月21日
- 2.7.6 → 2.17.6 no changes
- 2.6.7 2017年05月05日
- 2.1.4 → 2.5.6 no changes
- 2.0.5 2014年12月17日
名称
git-check-attr - 显示 gitattributes 信息
概述
git check-attr [--source <树状对象>] [-a | --all | <属性>…] [--] <路径名>… git check-attr --stdin [-z] [--source <树状对象>] [-a | --all | <属性>…]
描述
对于每个路径名,该命令将列出每个属性是否为 "未指定"、"已设置" 或 "未设置",作为该路径名的 gitattribute。
选项
- -a, --all
-
列出与指定路径相关的所有属性。 如果使用这个选项,那么 "未指定的" 属性将不包括在输出中。
- --cached
-
只考虑索引中的
.gitattributes,忽略工作区。 - --stdin
-
从标准输入中读取路径名,每行一个,而不是从命令行读取。
- -z
-
输出格式被修改为机器可解析的。 如果同时给出
--stdin,输入路径将用 NUL 字符而不是换行符来分隔。 - --source=<目录树对象>
-
根据指定的目录树型检查属性。通常通过命名与之相关的提交、分支或标记来指定源目录树。
- --
-
将前面的所有参数解释为属性,后面的所有参数解释为路径名称。
如果没有使用 --stdin、--all 或 --,第一个参数将被视为一个属性,其余的参数将被视为路径名。
输出
输出的形式是: <路径> COLON SP <属性> COLON SP <信息> LF
除非 -z 生效,在这种情况下,使用 NUL 作为分隔符: <路径> NUL <属性> NUL <信息> NUL
<路径> 是被查询的文件的路径,<属性> 是被查询的属性,<信息> 可以是任何一种:
- unspecified
-
当该属性未被定义为路径时。
- unset
-
当该属性被定义为 false 时。
- set
-
当该属性被定义为真时。
- <值>
-
当一个值被分配给该属性时。
缓冲发生在 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] 文档