git n个git分支之间的关系

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5298972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:11:46  来源:igfitidea点击:

Relationship between n git branches

gitbranchgit-branch

提问by Bjarke Freund-Hansen

If I have n git branches, how do I easily show the relationship between these branches?

如果我有 n 个 git 分支,如何轻松显示这些分支之间的关系?

Basically I am interested in seeing a tree of a subset of all the branches in my repository. I am however not interested in all the intermediate commits.

基本上我有兴趣看到我的存储库中所有分支的子集的树。然而,我对所有的中间提交都不感兴趣。

E.g.: My repository looks like this:

例如:我的存储库如下所示:

     o---o--o A
    /      /
o--o--o--o--o--o B
 \  \        \
  \  o--o C   \
   \     \     \
    o--o--o--o--o--o D

But probably way more complicated. Now I want to see the relationship between branch A, C and D. Something along the lines of:

但可能要复杂得多。现在我想看看分支 A、C 和 D 之间的关系。大致如下:

     o A
    /
o--o--o
   \   \
    o---o C
         \
          o--o D

Or an equivalent overview. Is this possible, and how? (A graphical tool will be just fine.)

或等效的概述。这是可能的,如何?(图形工具就可以了。)

Solution

解决方案

Based on Antoine Pelisses answer, the below line seems to do (almost) exactly what I want:

根据 Antoine Pelisses 的回答,下面这行似乎(几乎)正是我想要的:

git log --graph --decorate --oneline --simplify-by-decoration A B C

Update

更新

Mark Longair points out in his answer below that gitkaccepts the same parameters as git rev-list, so it is possible to do:

Mark Longair 在下面的回答中指出,它gitk接受与 相同的参数git rev-list,因此可以这样做:

gitk --simplify-by-decoration A C D

回答by Antoine Pelisse

You can give this a try:

你可以试试这个:

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

It will only show commits that are branch heads or tagged.

它只会显示分支负责人或标记的提交。

回答by Mark Longair

I would use:

我会用:

gitk A C D

... there are probably other git GUIs that produce a prettier rendering of the commit graph, but I've always found gitkfine for this purpose. All the branches and tags are labelled in the "London Underground"-style representation:

... 可能还有其他 git GUI 可以生成更漂亮的提交图渲染,但我一直觉得gitk这很好用。所有的分支和标签都以“伦敦地下”风格的表示方式标记:

A screenshot of gitk showing several merges and branches
(source: mark at mythic-beasts.com)

gitk 的截图,显示了几个合并和分支
(来源:mark at mythic-beasts.com



You can also use the --simplify-by-decorationoption to gitk, since it understands all of the parameters that git rev-listdoes, for example:

您还可以使用--simplify-by-decoration选项 to gitk,因为它可以理解所有参数,git rev-list例如:

gitk --simplify-by-decoration A C D

A screenshot of gitk with the --simplify-by-decoration option

带有 --simplify-by-decoration 选项的 gitk 屏幕截图