設定與配置
取得和建立專案
基本快照
分支與合併
分享與更新專案
檢查與比較
修補
除錯
電子郵件
外部系統
伺服器管理
指南
管理
底層命令
- 2.43.1 → 2.47.0 沒有變更
-
2.43.0
11/20/23
- 2.41.1 → 2.42.3 沒有變更
-
2.41.0
06/01/23
- 2.36.1 → 2.40.3 沒有變更
-
2.36.0
04/18/22
- 2.18.1 → 2.35.8 沒有變更
-
2.18.0
06/21/18
- 2.14.6 → 2.17.6 沒有變更
-
2.13.7
05/22/18
- 2.1.4 → 2.12.5 沒有變更
-
2.0.5
12/17/14
選項
- --tags
-
不要使用分支名稱,而僅使用標籤來命名提交
- --refs=<模式>
-
僅使用名稱符合給定 shell 模式的 refs。模式可以是分支名稱、標籤名稱或完整 refs 名稱。如果多次給定,則使用名稱符合任何給定 shell 模式的 refs。使用
--no-refs
來清除先前給定的任何 ref 模式。 - --exclude=<模式>
-
不要使用名稱符合給定 shell 模式的任何 ref。模式可以是分支名稱、標籤名稱或完整 refs 名稱。如果多次給定,當 ref 符合任何給定模式時,將排除該 ref。與 --refs 一起使用時,ref 僅在符合至少一個 --refs 模式且不符合任何 --exclude 模式時才作為匹配項使用。使用
--no-exclude
來清除排除模式清單。 - --all
-
列出從所有 refs 可到達的所有提交
- --annotate-stdin
-
通過將所有 40 個字元的 SHA-1 十六進制(例如 $hex)替換為 "$hex ($rev_name)" 來轉換 stdin。當與 --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
-
顯示唯一縮寫的提交物件作為後備。
範例
給定一個提交,找出它相對於本地 refs 的位置。假設有人告訴您有關該出色的提交 33db5f4d9027a10e477ccf054b2c1ab94f74c85a。當然,您會查看提交,但這只會告訴您發生了什麼,而不會告訴您上下文。
輸入 git name-rev
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a 33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99~940
現在您更明智了,因為您知道它發生在 v0.99 之前的 940 個修訂版本中。
您可以做的另一個好事情是
% git log | git name-rev --annotate-stdin
GIT
屬於 git[1] 套件的一部分