簡體中文 ▾ 主題 ▾ 最新版本 ▾ git-commit-graph 最後更新於 2.52.0

名稱

git-commit-graph - 寫入和驗證 Git commit-graph 檔案

概要

git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]
git commit-graph write [--object-dir <dir>] [--append]
			[--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits]
			[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]
			<split-options>

描述

管理序列化的 commit-graph 檔案。

選項

--object-dir

使用指定的目錄作為 packfiles 和 commit-graph 檔案的位置。此引數用於指定一個備用目錄,該目錄僅包含物件目錄,而不是完整的 .git 目錄。commit-graph 檔案應位於 <dir>/info 目錄中,packfiles 應位於 <dir>/pack 目錄中。如果目錄無法轉換為絕對路徑,或者與任何已知物件目錄不匹配,git commit-graph ... 將以非零狀態退出。

--progress
--no-progress

顯式開啟/關閉進度顯示。如果兩者都沒有指定,則當標準錯誤連線到終端時,將顯示進度。

命令

write

根據 packfiles 中找到的提交寫入 commit-graph 檔案。如果配置選項 core.commitGraph 被停用,則此命令將輸出一個警告,然後成功返回而不寫入 commit-graph 檔案。

使用 --stdin-packs 選項,透過遍歷指定 pack-indexes 中的物件來生成新的 commit graph。 (不能與 --stdin-commits--reachable 結合使用。)

使用 --stdin-commits 選項,透過遍歷 stdin 中指定的提交(以十六進位制 OID 列表的形式,每行一個 OID)來生成新的 commit graph。解析為非提交物件的 OID(直接解析或透過剝離標籤)將被靜默忽略。格式錯誤或不存在的 OID 將導致錯誤。(不能與 --stdin-packs--reachable 結合使用。)

使用 --reachable 選項,透過遍歷所有 ref 的提交來生成新的 commit graph。(不能與 --stdin-commits--stdin-packs 結合使用。)

使用 --append 選項,包含現有 commit-graph 檔案中存在的所有提交。

使用 --changed-paths 選項,計算並寫入有關提交與其第一個父提交之間更改的路徑資訊。此操作在大倉庫上可能需要一些時間。它為使用 git log -- <path> 獲取目錄或檔案的歷史記錄提供了顯著的效能提升。如果提供了此選項,未來的 commit-graph 寫入將自動假定已指定此選項。使用 --no-changed-paths 停止儲存此資料。--changed-paths 是透過配置 commitGraph.changedPaths=true 隱含的。

使用 --max-new-filters=<n> 選項,生成最多 n 個新的 Bloom 過濾器(如果指定了 --changed-paths)。如果 n-1,則不執行限制。只有新層中存在的提交才計入此限制。為了追溯性地計算早期層的 Bloom 過濾器,建議使用 --split=replace。覆蓋 commitGraph.maxNewFilters 配置。

使用 --split[=<strategy>] 選項,將 commit-graph 寫入為儲存在 <dir>/info/commit-graphs 中的多個 commit-graph 檔案鏈。Commit-graph 層根據策略和其他拆分選項進行合併。新新增到 commit-graph 的提交將新增到一個新的“尖端”檔案中。如果滿足以下合併條件,則此檔案將與現有檔案合併。

  • 如果指定了 --split=no-merge,則永遠不會執行合併,並且將忽略其餘選項。--split=replace 會用新的鏈覆蓋現有鏈。裸 --split 選項將按照其餘選項執行。(請注意,合併 commit graph 鏈會將現有鏈替換為長度為 1 的鏈,其中第一個也是唯一的增量持有整個圖)。

  • 如果未指定 --size-multiple=<X>,則令 X 等於 2。如果新的尖端檔案包含 N 個提交,而前一個尖端檔案包含 M 個提交,並且 X 乘以 N 大於 M,則將這兩個檔案合併為一個檔案。

  • 如果指定了 --max-commits=<M>M 為正整數,並且新的尖端檔案將包含超過 M 個提交,則將新的尖端與前一個尖端合併。

    最後,如果未指定 --expire-time=<datetime>,則令 datetime 為當前時間。寫入拆分的 commit-graph 後,刪除所有修改時間早於 datetime 的未使用的 commit-graph。

verify

讀取 commit-graph 檔案並將其內容與物件資料庫進行驗證。用於檢查損壞的資料。

使用 --shallow 選項,僅檢查已拆分 commit-graph 鏈中的尖端 commit-graph 檔案。

示例

  • 為本地 .git 目錄中的已打包提交寫入 commit-graph 檔案。

    $ git commit-graph write
  • 寫入 commit-graph 檔案,使用 <pack-index> 中的提交擴充套件當前的 commit-graph 檔案。

    $ echo <pack-index> | git commit-graph write --stdin-packs
  • 寫入一個包含所有可達提交的 commit-graph 檔案。

    $ git show-ref -s | git commit-graph write --stdin-commits
  • 寫入一個 commit-graph 檔案,該檔案包含當前 commit-graph 檔案中的所有提交以及從 HEAD 可達的提交。

    $ git rev-parse HEAD | git commit-graph write --stdin-commits --append

配置

本節中以下所有內容均從 git-config[1] 文件中選擇性地包含。內容與彼處相同:

commitGraph.generationVersion

指定寫入或讀取 commit-graph 檔案時使用的生成號版本型別。如果指定版本 1,則不會寫入或讀取已更正的提交日期。預設為 2。

commitGraph.maxNewFilters

指定 git commit-graph write--max-new-filters 選項的預設值(參見 git-commit-graph[1])。

commitGraph.changedPaths

如果為 true,則 git commit-graph write 將預設計算並寫入 changed-path Bloom 過濾器,相當於傳遞 --changed-paths。如果為 false 或未設定,則僅當過濾器已存在於當前 commit-graph 檔案中時,在 git commit-graph write 期間寫入 changed-paths Bloom 過濾器。這與不帶任何 --[no-]changed-paths 選項的 git commit-graph write 的預設行為一致。要重寫沒有過濾器的 commit-graph 檔案,請使用 --no-changed-paths 選項。命令列選項 --[no-]changed-paths 始終優先於此配置。預設為未設定。

commitGraph.readChangedPaths

已棄用。如果為 true,則等同於 commitGraph.changedPathsVersion=-1;如果為 false,則等同於 commitGraph.changedPathsVersion=0。(如果 commitGraph.changedPathVersion 也已設定,則 commitGraph.changedPathsVersion 優先。)

commitGraph.changedPathsVersion

指定 Git 將讀取和寫入的 changed-path Bloom 過濾器的版本。可以是 -1、0、1 或 2。請注意,大於 1 的值可能與不支援這些版本的舊版本 Git 不相容。在混合版本環境中操作時請小心。

預設為 -1。

如果為 -1,Git 將使用倉庫中 changed-path Bloom 過濾器的版本,如果不存在則預設為 1。

如果為 0,Git 不會讀取任何 Bloom 過濾器,並且在指示寫入時將寫入版本 1 的 Bloom 過濾器。

如果為 1,Git 只會讀取版本 1 的 Bloom 過濾器,並且會寫入版本 1 的 Bloom 過濾器。

如果為 2,Git 只會讀取版本 2 的 Bloom 過濾器,並且會寫入版本 2 的 Bloom 過濾器。

有關更多資訊,請參見 git-commit-graph[1]

檔案格式

GIT

Git[1] 套件的一部分