n个git分支之间的关系

发布于 2024-10-22 00:12:44 字数 789 浏览 4 评论 0原文

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

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

例如:我的存储库看起来像这样:

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

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

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

或等效概述。这可能吗?如何实现? (图形工具就可以了。)

解决方案

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

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

更新

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

gitk --simplify-by-decoration A C D

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

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:

     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:

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

Update

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

gitk --simplify-by-decoration A C D

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

茶花眉 2024-10-29 00:12:44

您可以尝试一下:

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

它只会显示分支头或标记的提交。

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.

泼猴你往哪里跑 2024-10-29 00:12:44

我会使用:

gitk A C D

...可能还有其他 git GUI 可以生成更漂亮的提交图渲染,但我总是发现 gitk 适合此目的。所有分支和标签都以“伦敦地铁”样式表示形式进行标记:

显示多个合并和分支的 gitk 屏幕截图
(来源:在 mythic-beasts.com 标记)< /sub>


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

gitk --simplify-by-decoration A C D

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

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 gitk fine for this purpose. All the branches and tags are labelled in the "London Underground"-style representation:

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


You can also use the --simplify-by-decoration option to gitk, since it understands all of the parameters that git rev-list does, for example:

gitk --simplify-by-decoration A C D

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文