Git分支的继承树 [英] Tree of inheritance of Git branches
问题描述
有没有办法在shell中复制Git分支的继承树?
Is there any way to replicate an inheritance tree of Git branches in shell?
例如,我有本地分支 b1 , b2 ,..., bN ,如git branch
所示.
For example, I have local branches b1, b2, ... , bN as listed by git branch
.
示例:
++ b7 <--+ b4
|
b8 <--+ b5 +-+ b2
| |
++ b1 <---+ b3
|
+-+ b6
因此,在上述情况下,我希望有一个代表分支名称的变量(或它们的哈希,没关系).
So, in the above case I would like to have a variables representing branch names (or their hashes, doesn't matter).
我了解壳中的二进制搜索树数据结构(至少一种运行良好的方法).问题是在将分支提交到类似BST的结构中时如何获得正确的左或右选择?
I know about binary search tree data structures in shell (at least one approach which is working nicely). The problem is how to get a proper left or right choice when submitting the branch into the BST-like structure?
我想我需要对git branch --contains
和git merge-base
做些事情,尽管我现在无法清楚地看到算法的图片. git branch --contains
的运行速度非常慢,可能是由于树的性质所致,也很可能听到其他声音.
I suppose I need to do something with git branch --contains
and git merge-base
, though I can't clearly see a picture of algorithm right now. The git branch --contains
works quite slowly, perhaps because of nature of the tree, it would be also good to hear alternatives.
libgit2
+ python方法对我来说似乎不是最好的选择,因为我需要重新设置这些分支的基础,并且libgit2
看来还很底层.
libgit2
+ python approach seems not the best choice to me because I need to rebase those branches and it looks like libgit2
is quite low level for that.
推荐答案
此命令的输出是否像您想要的那样:
Does this command's output look like what you want:
git log --oneline --graph --decorate --simplify-by-decoration --all
这篇关于Git分支的继承树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!