9
5

More than 3 years have passed since last update.

git log を1行表示にする+日付を表示する

Last updated at Posted at 2020-12-03

git log を1行表示にするには、以下のコマンドで実行できる。

git log --pretty=oneline

結果:

c00ebdb099430502f90718b4e2d15f51fc351e27 (HEAD -> develop, origin/develop, origin/HEAD) Merge branch 'xxxxx' into 'develop'

しかし、この表示方法だと、日時が表示できない。そこで、--pretty=format 使うことで、日付も併せて表示させることができる。

git log --pretty=format:'%H (%ai) %s'

結果:

c00ebdb099430502f90718b4e2d15f51fc351e27 (2020-11-12 13:13:23 +0900) Merge branch 'xxxxx' into 'develop'

フォーマットの種類

公式ページに一覧が載っているが、いくつか自分が使いそうなものをピックアップしておく。

フォーマット 意味
%H コミットID
%h コミットIDの短縮版
%ai 日時表示。日時表示にも色々種類があり、このフォーマットの場合、表示は「2020-11-26 09:16:07 +0800」となる。
%an コミットした人の名前
%ae コミットした人のメールアドレス
%s コミットメッセージ(タイトル)。Bodyを表示させるには %b を使える。

参考

9
5
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
9
5