Git:git logコマンドでコミット履歴をグラフで表示する方法

スポンサーリンク

git logコマンドでコミット履歴をグラフで表示する方法

git logコマンドでコミット履歴をグラフで表示するには--graphオプションを指定します。

 

オプションの説明

 --graph
     Draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between
     commits, in order for the graph history to be drawn properly. Cannot be combined with --no-walk.

     This enables parent rewriting, see History Simplification above.

     This implies the --topo-order option by default, but the --date-order option may also be specified.
 --oneline
     This is a shorthand for "--pretty=oneline --abbrev-commit" used together.
 -<number>, -n <number>, --max-count=<number>
     Limit the number of commits to output.

 

--graphオプションを指定した場合(-nオプションは出力するコミット数の指定、--onelineオプションは一行で出力するオプション)

$ git log --graph -n 10 --oneline
* 8b7c11b866 (HEAD -> master, origin/master, origin/HEAD) The fifth batch
*   96ac07f4a9 Merge branch 'ab/help-autocorrect-prompt'
|\
| * dc66e3c799 help.c: help.autocorrect=prompt waits for user action
* |   613204b948 Merge branch 'cb/ci-build-pedantic'
|\ \
| * | cebead1ebf ci: run a pedantic build as part of the GitHub workflow
* | |   9762646ee4 Merge branch 'gh/gitweb-branch-sort'
|\ \ \
| * | | a45e390ad6 gitweb: use HEAD as secondary sort key in git_get_heads_list()
* | | |   05665a0dff Merge branch 'rs/archive-use-object-id'
|\ \ \ \
| * | | | e124ecf7f7 archive: convert queue_directory to struct object_id
* | | | |   09f66eb0e2 Merge branch 'rs/show-branch-simplify'
|\ \ \ \ \

キャプチャ画像

git-log-graph

 

--graphオプションを指定しない場合

$ git log -n 10 --oneline
8b7c11b866 (HEAD -> master, origin/master, origin/HEAD) The fifth batch
96ac07f4a9 Merge branch 'ab/help-autocorrect-prompt'
613204b948 Merge branch 'cb/ci-build-pedantic'
9762646ee4 Merge branch 'gh/gitweb-branch-sort'
05665a0dff Merge branch 'rs/archive-use-object-id'
09f66eb0e2 Merge branch 'rs/show-branch-simplify'
bfe37f3dc5 Merge branch 'jk/log-warn-on-bogus-encoding'
a4b1a0ade4 Merge branch 'cb/remote-ndebug-fix'
fd0d7036e0 Merge branch 'ab/retire-advice-config'
6d09fc54f6 Merge branch 'mk/clone-recurse-submodules'