LoginSignup
15
7

More than 3 years have passed since last update.

[Git] git log の日時を見やすくする

Last updated at Posted at 2019-07-19

TL;DR

標準出力は日付部分のみを抜粋している。

$ git log
Wed Jul 10 15:59:02 2019 +0900
Tue Jul 16 02:36:47 2019 +0000

$ git log --date=iso-local
2019-07-10 15:59:02 +0900
2019-07-16 11:36:47 +0900

$ git log --date=format-local:'%Y/%m/%d %H:%M:%S'
2019/07/10 15:59:02
2019/07/16 11:36:47

説明

git log で表示される日時は (おそらく多くの日本人にとって) 読みにくい。

$ git log
Wed Jul 10 15:59:02 2019 +0900 # JST
Tue Jul 16 02:36:47 2019 +0000 # UTC

そこで --date オプションでフォーマットを指定する。iso-local (ISO 8601 形式) が読みやすい。

$ git log --date=iso-local
2019-07-10 15:59:02 +0900
2019-07-16 11:36:47 +0900

フォーマットに独自のものを指定したい場合は format-local を使う。format ではなく format-local を使うことで、タイムゾーンがローカルに統一される。

$ git log --date=format:'%Y/%m/%d %H:%M:%S'
2019/07/10 15:59:02
2019/07/16 02:36:47

$ git log --date=format-local:'%Y/%m/%d %H:%M:%S'
2019/07/10 15:59:02
2019/07/16 11:36:47

参考

15
7
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
15
7