簡體中文 ▾
主題 ▾
最新版本 ▾ 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