我对图形git log的输出非常困惑。

我确实知道每个*都意味着一个提交,无论它是发散,通用还是合并提交。
我知道管道意味着分支。

让我们看一个简单的图形日志:

首先,红色管道(最左撇子)代表哪个分支?我不认为这是我当前所在的分支,因为 checkout 到其他分支后,该图看起来相同。此外,它也不代表master分支。

第二,如果最左手的分支代表单个分支,为什么在提交“0e5b5”后它会更改颜色?

我搜索了一个有关如何阅读git日志图的教程,不幸的是,我一无所获。如果有关于这个主题的很棒的教程,请随时分享。

最佳答案

Git从当前致力于祖先的提交工作。分支不是“实体”,它们是(移动的)引用。 git log(或具有不同配色方案但类似于git log --graph或tig的gitk)无法知道当前分支是分支A还是分支B的后代。它仅了解父级。从man git-log:

   git log -p -m --first-parent
       Shows the history including change diffs, but only from the "main
       branch"   perspective, skipping commits that come from merged
       branches, and showing full diffs of changes introduced by the merges.
       This makes sense only when following a strict policy of merging
       all topic branches when staying on a single integration branch.

会在某种程度上解决您的担忧。 git log默认使用当前 checkout 的提交作为引用(与执行git log HEAD相同

虽然我个人认为git的手册页很清楚,但您可能想看看gitk或tig。前者是图形界面,而后者是类似终端​​的最小gitk工具。两者都取决于我想做什么。

关于git - 如何理解git log --graph,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20200226/

10-13 05:44