简体中文 ▾
主题 ▾
最新版本 ▾ git-name-rev 最后更新于 2.43.0
git-name-rev 手册中的更改
设置和配置
获取和创建项目
基本快照
分支与合并
共享和更新项目
检查和比较
打补丁
调试
电子邮件
外部系统
服务器管理
指南
管理
底层命令
- 2.43.1 → 2.50.1 无更改
-
2.43.0
2023-11-20
- 2.41.1 → 2.42.4 无更改
-
2.41.0
2023-06-01
- 2.36.1 → 2.40.4 无更改
-
2.36.0
2022-04-18
- 2.18.1 → 2.35.8 无变更
-
2.18.0
2018-06-21
- 2.14.6 → 2.17.6 无更改
-
2.13.7
2018-05-22
- 2.1.4 → 2.12.5 无变化
-
2.0.5
2014-12-17
选项
- --tags
-
不使用分支名称,仅使用标签来命名提交
- --refs=<pattern>
-
只使用名称匹配给定 shell 模式的引用。模式可以是分支名称、标签名称或完全限定的引用名称。如果多次给出,则使用名称匹配任何给定 shell 模式的引用。使用
--no-refs
清除之前给出的所有引用模式。 - --exclude=<pattern>
-
不使用任何名称匹配给定 shell 模式的引用。模式可以是分支名称、标签名称或完全限定的引用名称。如果多次给出,当引用匹配任何给定模式时,将被排除。与 --refs 一起使用时,只有当引用匹配至少一个 --refs 模式且不匹配任何 --exclude 模式时,才会被视为匹配。使用
--no-exclude
清除排除模式列表。 - --all
-
列出所有可从所有引用访问的提交
- --annotate-stdin
-
通过将所有 40 字符 SHA-1 十六进制(例如 $hex)替换为“$hex ($rev_name)”来转换标准输入。与 --name-only 一起使用时,替换为“$rev_name”,完全省略 $hex。此选项在 Git 的旧版本中称为
--stdin
。例如
$ cat sample.txt An abbreviated revision 2ae0a9cb82 will not be substituted. The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad $ git name-rev --annotate-stdin <sample.txt An abbreviated revision 2ae0a9cb82 will not be substituted. The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad $ git name-rev --name-only --annotate-stdin <sample.txt An abbreviated revision 2ae0a9cb82 will not be substituted. The full name after substitution is master, while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad
- --name-only
-
只打印名称,而不是同时打印 SHA-1 和名称。如果与 --tags 一起使用,名称中通常的“tags/”标签前缀也会被省略,使其更接近
git-describe
的输出。 - --no-undefined
-
当引用未定义时,以非 0 错误码退出,而不是打印
undefined
。 - --always
-
显示唯一缩写的提交对象作为回退。
示例
给定一个提交,找出它相对于本地引用的位置。假设有人告诉你关于那个神奇的提交 33db5f4d9027a10e477ccf054b2c1ab94f74c85a。当然,你会查看这个提交,但这只告诉你发生了什么,而不是上下文。
输入 git name-rev
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a 33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99~940
现在你更聪明了,因为你知道它发生在 v0.99 之前的 940 个修订版本。
你可以做的另一件好事是
% git log | git name-rev --annotate-stdin