In Git, can you retrieve the date when you pulled a certain commit from the repo?

StackOverflow https://stackoverflow.com/questions/23478816

  •  16-07-2023
  •  | 
  •  

Frage

I reopened a bug but when asked to confirm it ("That's addressed in commit XYZ"), it went away. I don't remember doing a pull request after filing the bug (but then again, I'm busy...), so a part of me wonders if it's an intermittent or configuration-dependent bug.

Is there a way for me to see a log of when I pulled (in other words, not the commit dates but the dates I got the changes)?

War es hilfreich?

Lösung

When you do a git pull (or git merge after git fetch), this updates the reflog for the branch.

The reflog contains the date of the reflog update, mainly so that the reflog entry can expire after 3 months,1 but it's possible to show that date. That will be just what you want.

git reflog does not have a way to show this date. However, git log -g uses the reflog to show commits, and shows the reflog entry corresponding to those commits. By default this is shown as, e.g., master@{1}, but if you kick it off with @{now}, git log shows the reflog entry in date format:

$ git log -g master@{now}
commit 779792a5f24bb4e8049c4f88ad752e70d4a8a080
Reflog: master@{Tue Apr 22 13:34:07 2014 -0600} (me...)
Reflog message: merge origin/master: Fast-forward
Author: Junio C Hamano <gitster@pobox.com>
Date:   Mon Apr 21 11:54:29 2014 -0700

That was the last time I did a git merge after a git fetch, on the source for git itself. Here's an earlier pull example from when I was lazier for git 1.9-rc0:

commit 79fcbf7e703ca5805ebd46b2c7e09d0703f1c1ff
Reflog: master@{Sat Jan 18 23:32:22 2014 -0700} (me...)
Reflog message: pull: Fast-forward
Author: Junio C Hamano <gitster@pobox.com>
Date:   Fri Jan 17 12:30:14 2014 -0800

190 days by default, for reachable references, anyway; 30 days, by default, for reflog entries where the identified commit is not reachable from the current branch-tip; and both are tunable.


Edit to add note: you can also look at the reflog for the remote (e.g., git log -g origin/master@{now}) to see when changes were fetched. If you're using git pull, which does the merge immediately upon the point where the fetch finishes, these will show the same time periods, but it's worth noting that the remote reflogs are updated at fetch-time. (This was in another answer that has since been deleted.)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top