git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Guyot <tguyot@gmail.com>
To: Gerriko io <gerriko.iot@gmail.com>, git@vger.kernel.org
Subject: Re: Why is reflog so obscure?
Date: Mon, 11 Jul 2022 18:55:09 -0400	[thread overview]
Message-ID: <f0bb8ee8-9b38-45a7-a54b-24cf245bb3c8@gmail.com> (raw)
In-Reply-To: <CALF=2ANoq1eL-RqK_dLaVThoxbvfhzgPJXFHyD1kX8CFCPx3XA@mail.gmail.com>

On 2022-07-11 17:02, Gerriko io wrote:
> I am trying to make sense of reflog as I need to know this to use
> revert and reset properly.
>
> I cannot find the most basic information in the git documentation or online.
>
> Surely the most basic question is whether the reflog is sequential or
> just random logs or whether it is in time ascending or descending
> order.
>
> Without this information I am left baffled and have to guess what this
> line means out of the many:
>
> a0bbd34 (HEAD -> master, origin/master, origin/main)
> refs/remotes/origin/main@{0}: update by push
>
> Why does it have to be so obscure?

Hi,

The reflog is simply a log of where you've been, in descending order 
(latest entry first), and is branch agnostic. It show every commit 
you've been on from latest to oldest, and each entry can be heads, tags, 
or detached commits. Some operations like rebase may even generate 
multiple entries if it's done in multiple steps (ex conflicts resolution).

I believe its main uses are to delay garbage collect (which happens only 
after entries have expired form the reflog) and to allow refs selection 
using @{date} and @{nth} specifiers (see git-rev-parse, and note @{date} 
is not the commit date but rather the reflog date!)... And it's 
obviously quite handy to recover a dropped/rewritten ref if you realize 
you need to undo what you've done.

Since the date is recorded for each entry you can also display it using 
the --date=<format> option. For example to display reflog entries in 
local human-readable time, use:

git reflog --date=local

The git-reflog log display options are mostly the same as git-log and 
documented in git-log's manpage.

Regards,

--
Thomas

  reply	other threads:[~2022-07-11 22:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 21:02 Why is reflog so obscure? Gerriko io
2022-07-11 22:55 ` Thomas Guyot [this message]
2022-07-12  7:12   ` Jeff King
2022-07-12  9:22     ` Thomas Guyot
2022-07-12 14:23       ` Junio C Hamano
2022-07-12 15:18         ` Sergey Organov
2022-07-12 15:50           ` Junio C Hamano
2022-07-14  0:03             ` Thomas Guyot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0bb8ee8-9b38-45a7-a54b-24cf245bb3c8@gmail.com \
    --to=tguyot@gmail.com \
    --cc=gerriko.iot@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).