設定和配置
獲取和建立專案
基本快照
分支與合併
共享和更新專案
檢查和比較
打補丁
除錯
電子郵件
外部系統
伺服器管理
指南
管理
底層命令
- 2.43.1 → 2.52.0 無更改
-
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
-
當引用未定義時,以非零退出碼退出,而不是列印
undefined。 - --always
-
顯示唯一的縮寫提交物件作為回退。
示例
給定一個提交,找出它相對於本地引用的位置。假設某人寫信給你說有一個很棒的提交 33db5f4d9027a10e477ccf054b2c1ab94f74c85a。當然,你查看了那個提交,但這隻告訴你發生了什麼,但沒有上下文。
輸入 git name-rev
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a 33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99~940
現在你更明智了,因為你知道它發生在 v0.99 之前的 940 個修訂版本。
你還可以做另一件 nice 的事情:
% git log | git name-rev --annotate-stdin