1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git pull した時間を知りたい

Last updated at Posted at 2018-11-26

git pull した時間を知りたいことってよくあるのですが、意外と調べても出てこなかったのでメモ
「そんなもん変更されたファイルのタイムスタンプ見ればいいじゃん」ということでみんなわざわざ書いてないのかもしれません
たしかに
git log --stat
とでもして変更されたファイルを調べて、そのファイルのタイムスタンプを見れば git pull された時間はわかります
しかし、 pull された後に誰かがいじってるかもしれないし、 pull したときに何もファイルは変更されなかったけど、 pull を実行した時間は知りたいとかいう時もないわけではないし、スクリプトで自動的に取得したいこともあるわけです
そんなときは FETCH_HEAD ファイルのタイムスタンプを見ましょう
ls -l .git/FETCH_HEAD
取得した日時をスクリプトで利用するようなときは
stat -c %Y .git/FETCH_HEAD
などとしてunixtimestampで取得するのも良いかもしれません
git pull じゃなくて git fetch, git merge, git rebase を使っている場合は FETCH_HEAD は fetch した時間になるので、 merge や rebase した時間を知るためには ORIG_HEAD のタイムスタンプを見たほうが良いようです
ls -l .git/ORIG_HEAD

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?