I am wondering if there is a way to view a push date associated with each commit in the git log. If that is not possible, is there a way to see all the commits under a certain push.
I writing a program that needs to keep track of the commits as they are pushed. Because the git log is ordered by the commit date, not the push date, I am not able to see the most recent commits that are pushed. For example, if a user commits to his local repository 2 days before he pushes to the master, that commit will be placed behind 2 days of other commits in the master repository log.
It took me an insanely long time to gather scattered information and finally find the very best answer to this question, but now I know I have it. In just two lines, no code and no hooks:
# required for a bare repo
git config core.logAllRefUpdates true
git reflog --date=local master
Simple at last.
Warning: you probably want to override the default values of gc.reflogExpire
and gc.reflogExpireUnreachable
. Check git help reflog
for details and to understand how and why this works.
The two commands above must be run inside the clone you push to. If that is not possible then an approximation is to run in another, permanent clone:
git fetch origin # often and *regularly*
git reflog --date=local origin/master
Never delete this permanent clone or you will lose the dates.