Search code examples
gitgit-reflog

Can I view the reflog of a remote (not remote ref)?


Is it possible to view the reflog of a remote? That is, I want to know what the output of git reflog is on another remote machine.

Note that I am not asking for the reflog of remote-tracking branches (such as origin/master); I am asking for what reflog says on the other machine.


Solution

  • The answer is basically "no" (except on that machine), because the reflog is a log of locally-made re-assignments of some ref-name. Essentially, every time you run git update-ref -m msg <name> <target> the update is logged ... locally: .git/logs/<name> gets a line appended:

    $ git update-ref -m foo HEAD HEAD^
    $ tail -1 .git/logs/HEAD
    2418b6ba8fd0289933c9351260a272b8e410867f 8d945134b0cead535d66af29c8eb4228b5dc3763 [redacted] <[redacted]> 1334106483 -0600     foo
    

    (the thing before the message, in this case foo, is not spaces but rather a tab; I expanded it for SO purposes). Conceptually, everything else that moves a branch tip invokes git update-ref to do it (some are shell scripts and literally do that, others just invoke the C code that does all the file-updating) ... and everything in .git/logs makes up the reflog.

    If there were things in the underlying git:// and/or ssh:// protocols that let you get at the reflog, that would do it, but as far as I know there isn't.