在命令行显示分支层次结构? [英] Showing branch hierarchy at the command line?

查看:82
本文介绍了在命令行显示分支层次结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇有没有办法在命令行上显示分支层次结构?例如,如果我使用 git branch ,而不是像这样看到输出:

  * master 
joes_work
重构
实验

您会看到输出是这样的:

$ $ $ $ $ $ $ $ $ b $ $ $ $ $ $ $ / code>

通过这种方式可以很容易地看到某个分支从哪个分支分支出来。即使没有输出树结构的特定命令,是否有输出关于哪个分支来自哪个分支的信息的命令?我可以使用perl脚本来格式化输出。

解决方案

sehe的解决方案看起来不错,这里是另一个似乎包含类似信息,格式不同,它使用git log,所以它也包含提交信息(忽略分支名称,我把它们搞砸了):

  git log --all --graph --decorate --oneline --simplify by by decoration 

* ae038ad(HEAD,branch2-1)将内容添加到tmp1
| * f5a0029(branch2-1-1)添加另一个
| /
* 3e56666(branch1)第二波提交
| * 6c9af2a(branch1-2)add thing
| /
* bfcf30a(master)commit 1


I'm curious if there is a way to show branch hierarchy on the command line? For instance if I use git branch, instead of seeing output like this:

* master
joes_work
refactoring
experiment

You see output like this:

* master
    joes_work
    refactoring
        experiment

That way it's easy to see which branch a particular branch.. branched off of. Even if there's no specific command that outputs a tree structure, is there a command that outputs information on which branch came from which branch? I can use a perl script to format the output.

解决方案

sehe's solution looks great, here is another one that seems to contain similar information, formatted differently, it uses git log, so it contains commit information as well (ignore the branch names, I kind of messed them up!):

git log --all --graph --decorate --oneline --simplify-by-decoration

* ae038ad (HEAD, branch2-1) add content to tmp1
| * f5a0029 (branch2-1-1) Add another
|/  
* 3e56666 (branch1) Second wave of commits
| * 6c9af2a (branch1-2) add thing
|/  
* bfcf30a (master) commit 1

这篇关于在命令行显示分支层次结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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