R's Workshop

Git Commit Graph for Faster Visualized Log Display

在開大型 git project (e.g. linux) 的 log 時, 常會花上幾秒鐘的時間讀取. 原因是 git 需要重複做以下動作: 讀取 commit 的 content –> 找到 parent commit –> 讀取 parent commit 的 content –> (loop). 為了加速 log 的讀取, git 提供了 git commit-graph 指令來建立一個簡化 parrent commit 讀取速度的簡易 graph database.

Commit Graph

生成的 commit graph 會放在 .git/objects/info/commit-graph. Commit graph 裡包含 object ID, parent relationships, commit date and root tree information.

Automatic Graph Update

Method 1:

git config fetch.writeCommitGraph=true

Method 2:

git maintenance start

Reference

Git