如何理解git log --graph [英] How to understand git log --graph

查看:406
本文介绍了如何理解git log --graph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我明白每个 * 意味着一个提交,无论它是一个分歧,共同或合并提交。
我明白管道意味着分支。



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



首先,分支做的红色管(最左手的)代表什么?我不认为这是我目前的分支,因为在我结账到其他分支之后,图表看起来是一样的。此外,它也不代表主分支。第二,如果最左手的分支代表一个分支,为什么它在提交0e5b5之后改变颜色?



我搜索了关于如何阅读git log图表的教程,不幸的是,我什么也没得到。如果有关于这个主题的一些真棒教程,请随时分享。

。分支不是实体,它们是(移动)参考。 git log(或者gitk具有不同的配色方案,但与git log --graph或tig类似)无法知道当前分支是分支A还是分支B的后代。它只知道父母。从man git-log:

  git log -p -m --first-parent 
显示包含更改的历史记录不过,只能从主
分支的角度来看,跳过来自合并
分支的提交,并显示由合并引入的更改的完全差异。
只有遵循严格的合并
所有主题分支的政策时,这才有意义。

有点可以解决您的问题。 git log默认情况下使用当前签出的提交作为参考(与执行 git log HEAD



相同虽然我personnaly认为man page对于git来说非常明显,你可能想看看gitk或者tig,前者是一个图形界面,后者是一个类似终端的最小gitk工具,两者都取决于我想做什么。

I am quite confused with the output of graphic git log.

I do understand that each * means a commit, whether it is a diverge, common or merge commit. I do understand that pipes means branch.

Let's look at a simple graph log:

First of all, which branch does the red pipe (the most left-handed one) represent for? I don't think it is the current branch that I am on, because after I checkout to other branch, the graph looks the same. Furthermore, it doesn't represent master branch neither.

Second of all, if the most left-handed branch represents a single branch, why it changes color after commit "0e5b5"?

I searched for a tutorial on how to read git log graphs, unfortunately, I got nothing. If there are some awesome tutorials on this topic, please feel free to share.

解决方案

Git works from the current commit looking at ancestors. Branches are not "entities", they are (moving) references. There is no way for git log (or gitk which has a different color scheme but is analoguous to git log --graph or tig) to know if the current branch is the descendant of branch A or branch B. It only knows parents. From 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.

Would somewhat address your concern. git log by default use current checked out commit as a reference (identical to executing git log HEAD

While I personnaly think the man page is quite clear for git, you may want to take a look at gitk or tig. The former is a graphical interface the later is a terminal-like minimal gitk tool. I use both depending on what I want to do.

这篇关于如何理解git log --graph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆