I found myself needing to know if I had pushed something before or after some operational event. The commit itself was dated late on Friday before the event; could it have been deployed then, or did I wait until Monday to push?
It turns out that git reflog
has the answers; as it's a log of what the branch tip pointed to, it logs commits, amends, and push/pull activity. It doesn't normally include a date in the output, but we can convince it to give us one by using the --pretty
formatting option.
git reflog --pretty='%cd %h %gd %gs'
This format means “commit date”, Thu Nov 28 17:56:08 -0500
style; the hash; the “shortened reflog selector,” like HEAD{1}
; and finally, the reflog summary, which has information like commit (amend): Awesome subject line
.
Within the reflog, for push/pull events, the “commit date” is actually the date of the push/pull completing its task.
The major limitation here is that the reflog is local; we can only look at our own activity with this method.
However, in my situation, that was enough to exonerate my commit, allowing us to turn our attention elsewhere for an explanation.
No comments:
Post a Comment