設定和配置
獲取和建立專案
基本快照
分支與合併
共享和更新專案
檢查和比較
打補丁
除錯
電子郵件
外部系統
伺服器管理
指南
管理
底層命令
- 2.46.1 → 2.52.0 無更改
-
2.46.0
2024-07-29
- 2.43.1 → 2.45.4 無更改
-
2.43.0
2023-11-20
- 2.42.1 → 2.42.4 無更改
-
2.42.0
2023-08-21
- 2.39.1 → 2.41.3 無變更
-
2.39.0
2022-12-12
- 2.38.1 → 2.38.5 無更改
-
2.38.0
2022-10-02
- 2.22.1 → 2.37.7 無更改
-
2.22.0
2019-06-07
- 2.19.3 → 2.21.4 無更改
-
2.19.2
2018-11-21
- 2.18.1 → 2.19.1 無變更
-
2.18.0
2018-06-21
- 2.10.5 → 2.17.6 無變更
-
2.9.5
2017-07-30
- 2.1.4 → 2.8.6 無變更
-
2.0.5
2014-12-17
概要
git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]
[--current] [--color[=<when>] | --no-color] [--sparse]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics]
[(<rev> | <glob>)…]
git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]
描述
以半圖形化的方式,從
一次最多隻能顯示 26 個分支和提交。
如果在命令列中沒有給出 <rev> 或 <glob>,則使用 showbranch.default 多值配置項。
選項
- <rev>
-
任意擴充套件的 SHA-1 表示式 (參見 gitrevisions[7]),通常用於命名分支頭或標籤。
- <glob>
-
一個匹配 refs/ 下分支或標籤名稱的 glob 模式。例如,如果你在 refs/heads/topic 下有許多主題分支,給出
topic/*將會顯示所有這些分支。 - -r
- --remotes
-
顯示遠端跟蹤分支。
- -a
- --all
-
同時顯示遠端跟蹤分支和本地分支。
- --current
-
使用此選項時,如果未在命令列中給出當前分支,則該命令會將當前分支包含在要顯示的分支列表中。
- --topo-order
-
預設情況下,分支及其提交以反向時間順序顯示。此選項使它們按拓撲順序顯示 (即,後代提交顯示在其父提交之前)。
- --date-order
-
此選項與
--topo-order類似,在沒有父提交先於其所有子提交出現的情況下,提交是根據其提交日期排序的。 - --sparse
-
預設情況下,輸出會省略僅從顯示的一個提示中可達的合併。此選項使它們可見。
- --more=<n>
-
通常,命令在顯示所有分支的共同祖先的提交後停止輸出。此標誌告訴命令在超出該點後繼續顯示 <n> 個共同提交。當 <n> 為負數時,只顯示給定的 <ref>,而不顯示提交祖先樹。
- --list
-
--more=-1的同義詞 - --merge-base
-
不顯示提交列表,而是確定指定提交的可能合併基。所有合併基都將包含在所有指定的提交中。這與 git-merge-base[1] 處理三個或更多提交的情況不同。
- --independent
-
在給定的 <ref> 中,只顯示那些無法從任何其他 <ref> 達到的 <ref>。
- --no-name
-
不顯示每個提交的命名字串。
- --sha1-name
-
不使用從分支頭到達它們的路徑來命名提交 (例如,“master~2” 表示“master”的祖父),而是使用其物件名稱的唯一字首來命名它們。
- --topics
-
只顯示不在第一個給定分支上的提交。這有助於跟蹤主題分支,透過隱藏主開發線中已有的任何提交。當給出“git show-branch --topics master topic1 topic2”時,這將顯示“git rev-list ^master topic1 topic2”提供的修訂。
- -g
- --reflog[=<n>[,<base>]] [<ref>]
-
顯示給定引用的 <n> 條最近的 reflog 條目。如果給出了 <base>,則顯示從該條目回溯的 <n> 條。<base> 可以指定為計數或日期。當沒有給出顯式的 <ref> 引數時,預設為當前分支 (如果 detached,則為
HEAD)。 - --color[=<when>]
-
為每個提交的狀態符號 (以下之一:
*!+-) 著色,該狀態符號對應於該提交所在的分支。該值必須是 always (預設)、never 或 auto。 - --no-color
-
關閉彩色輸出,即使配置檔案指定預設彩色輸出。與
--color=never相同。
請注意,--more、--list、--independent 和 --merge-base 選項是互斥的。
輸出
給定 N 個 <ref>,前 N 行是其提交訊息的單行描述。由 $GIT_DIR/HEAD 指向的分支頭前面會加上星號 * 字元,而其他分支頭則前面加上 ! 字元。
在這些 N 行之後,會顯示每個提交的單行日誌,縮排 N 個位置。如果一個提交在第 I 個分支上,則第 I 個縮排字元顯示一個 + 符號;否則顯示一個空格。合併提交用 - 符號表示。每個提交顯示一個短名稱,該名稱可以用作擴充套件的 SHA-1 來命名該提交。
以下示例顯示了三個分支,“master”、“fixes”和“mhf”。
$ git show-branch master fixes mhf * [master] Add 'git show-branch'. ! [fixes] Introduce "reset type" flag to "git reset" ! [mhf] Allow "+remote:local" refspec to cause --force when fetching. --- + [mhf] Allow "+remote:local" refspec to cause --force when fetching. + [mhf~1] Use git-octopus when pulling more than one head. + [fixes] Introduce "reset type" flag to "git reset" + [mhf~2] "git fetch --force". + [mhf~3] Use .git/remote/origin, not .git/branches/origin. + [mhf~4] Make "git pull" and "git fetch" default to origin + [mhf~5] Infamous 'octopus merge' + [mhf~6] Retire git-parse-remote. + [mhf~7] Multi-head fetch. + [mhf~8] Start adding the $GIT_DIR/remotes/ support. *++ [master] Add 'git show-branch'.
這三個分支都從一個共同的提交 [master] 分叉出來,該提交的訊息是“Add 'git show-branch'”。“fixes”分支添加了一個提交“Introduce 'reset type' flag to 'git reset'”。“mhf”分支添加了許多其他提交。當前分支是“master”。
示例
如果你將主要分支放在 refs/heads 的正下方,並將主題分支放在其子目錄中,則在配置檔案中包含以下內容可能會有幫助:
[showbranch] default = --topo-order default = heads/*
有了這個,不帶額外引數的 git show-branch 只會顯示主要分支。此外,如果你碰巧在你的主題分支上,它也會被顯示。
$ git show-branch --reflog="10,1 hour ago" --list master
顯示從 1 小時前的尖端開始的 10 個 reflog 條目。不帶 --list,輸出還顯示了這些尖端之間是如何在拓撲上相互關聯的。
配置
本節中以下所有內容均從 git-config[1] 文件中選擇性地包含。內容與彼處相同:
- showBranch.default
-
git-show-branch[1] 的預設分支集。參見 git-show-branch[1]。