How do I view a git repo's receive history?
Asked Answered
A

1

17

We have a "central" repo that we use to deploy to our development server. I know git log will show me commits and the date/time they were committed, but I'd like to see when commits were pushed to/received by the repo. Any way to do this?

Archiphoneme answered 6/10, 2010 at 19:34 Comment(1)
I don't know of any builtin behavior, but you could probably hack a logger with a post-receive hook.Grandeur
N
24

Git’s reflogs will record your specified data (date, and new tip commit).

If your central repository is bare, then its reflogs are probably not enabled (they are not enabled by default when creating a bare repository). Enable them like this:

git config core.logAllRefUpdates true

You should also consider reviewing the other configuration options related to the reflogs (see git-config(1) and search for “reflog”): gc.reflogexpire, gc.reflogexpireunreachable.

You may also want to enable receive.denyDeletes (since a reflog is deleted when its branch is deleted). If you are only concerned with preserving the reflogs on certain branches then you could implement your own pre-branch “deny delete” with a receive or update hook (see githooks(5)).

Once you have enabled the reflogs you can review their contents with either
git reflog show branch-name or
git log -g branch-name (either may be combined with other git log options).

This will still not include other information that you may want (like who was pushing the new tip*), but it might help.
* The problem is that the authentication system (SSH, SSH+gitolite, HTTP, HTTP+git-http-backend, etc.) does not usually pass this information down to the level that records the new reflog entry; I recall that some organization (Gentoo?) was exploring something that would help record this information (as they are/were considering migrating to Git), but I do not recall the details).

Nether answered 6/10, 2010 at 22:51 Comment(2)
Perfect. To add to this, when running just git log -g branch-name it only gives the number of changes since that change (so the latest is 0, previous is 1, etc), but running git log -g --date=local branch-name will give a date instead. Thanks!Burglarize
@Mark this has saved my bacon as my team keep telling me they've pushed when in fact they've just committed. Now I'll be able to check before building. Happy days.Cb

© 2022 - 2024 — McMap. All rights reserved.