LoginSignup
125
103

More than 5 years have passed since last update.

git logを見やすくしたい!

Last updated at Posted at 2017-04-09

普通にgit logをすると、

image

となります。もっと見やすくしてみましょう!

1行表示

git logには色々オプションが指定出来ます。
例えば、

git log --oneline

image
のように1行で表示されます。
でも情報が簡素過ぎるので、

git log --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=iso

とすると、

image

という表示に出来ます。
毎回このパラメータを指定するのも面倒なので、~/.gitconfigに登録しておきましょう。
~/.gitconfig ファイルの[alias]セクションに以下を追加します。

[alias]
    plog = log --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=iso

これで次回からは、

git plog

で同じ表示が得られます。

追加オプション

  • 出力行数指定
git plog -3

image

  • マージコミットを除く
git plog --no-merges

image

  • ネットワーク図
git plog --graph

image
Windows環境であれば SourceTree 使った方がいいですね。。

- 全部入り(HEAD,ブランチ,リモートブランチ,タグ,stash)

git plog --all --graph

image
stashも履歴にぶら下がるんですね。
ある意味、こっそりコミット?して、特殊なブランチ名(stash)が付けられたもの、という解釈をすればいいんでしょうか。

私はこの全部入りを普段使っています。

[alias]
    glog = log --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=format:'%c' --all --graph

(参考)
git log

125
103
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
125
103