`git log --all --graph` 如何获取分支模式 [英] How does `git log --all --graph` get the branch pattern

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

问题描述

git log --all --graph 显示我的提交并在它们旁边绘制一个分支图.

git log --all --graph shows my commits and draws a branch graph besides them.

但是如果我查看git log命令输出的原始信息,分支名称仅适用于每个分支中的最后一次提交(分支提示).

But if I look at the raw information outputted by the git log command, the branch name is only available for the last commit in each branch (the branch tip).

我过去合并和删除的分支甚至不显示为名称(它们没有活动提示),但图形仍然正确呈现它们.

Branches I've merged and deleted in the past don't even show up as names (they have no active tip), but still the graph renders them correctly.

git 如何检索这些信息以及如何通过解析某些 git 命令的输出来获取相同的信息?(即:哪个 git 命令生成所需的信息?)

How does git retrieve this information and how can I get the same information by parsing the output of some git command? (That is: Which git command produces the needed information?)

推荐答案

绘制该图形所需的只是每次提交的父项.如果一次提交有多个父级,则为合并提交.

All you need to draw that graph are the parents for each commit. If a commit has more than one parent, it's a merge commit.

您可以使用普通的 git log 查看此信息.如果提交是合并,您会看到一行 Merge: 0123456 9abcdef.或者,您可以使用 git log --parents.然后 Commit: 行包括提交的哈希值以及所有父级的哈希值.

You can see this information with a plain git log. If a commit is a merge, you see a line Merge: 0123456 9abcdef. Alternatively you can use git log --parents. Then the Commit: line includes the commit's hash as well as all parents' hashes.

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

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