Tree of inheritance of Git branches

Deadly 提交于 2020-01-06 07:08:51

问题


Is there any way to replicate an inheritance tree of Git branches in shell?

For example, I have local branches b1, b2, ... , bN as listed by git branch.

Example:

     ++ 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).

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?

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 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.


回答1:


Does this command's output look like what you want:

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


来源:https://stackoverflow.com/questions/49478015/tree-of-inheritance-of-git-branches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!