Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
386 views
in Technique[技术] by (71.8m points)

branch - Relationship between n git branches

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...