How to understand git log --graph

前端 未结 3 681
面向向阳花
面向向阳花 2021-02-07 01:58

I am quite confused with the output of graphic git log.

I do understand that each * means a commit, whether it is a diverge, common or merge commit. I do un

3条回答
  •  不思量自难忘°
    2021-02-07 02:41

    Git works from the current commit looking at ancestors. Branches are not "entities", they are (moving) references. There is no way for git log (or gitk which has a different color scheme but is analoguous to git log --graph or tig) to know if the current branch is the descendant of branch A or branch B. It only knows parents. From man git-log:

       git log -p -m --first-parent
           Shows the history including change diffs, but only from the "main 
           branch"   perspective, skipping commits that come from merged
           branches, and showing full diffs of changes introduced by the merges. 
           This makes sense only when following a strict policy of merging
           all topic branches when staying on a single integration branch.
    

    Would somewhat address your concern. git log by default use current checked out commit as a reference (identical to executing git log HEAD

    While I personnaly think the man page is quite clear for git, you may want to take a look at gitk or tig. The former is a graphical interface the later is a terminal-like minimal gitk tool. I use both depending on what I want to do.

提交回复
热议问题