* Why is reflog so obscure?
@ 2022-07-11 21:02 Gerriko io
2022-07-11 22:55 ` Thomas Guyot
0 siblings, 1 reply; 8+ messages in thread
From: Gerriko io @ 2022-07-11 21:02 UTC (permalink / raw)
To: git
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?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-11 21:02 Why is reflog so obscure? Gerriko io
@ 2022-07-11 22:55 ` Thomas Guyot
2022-07-12 7:12 ` Jeff King
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Guyot @ 2022-07-11 22:55 UTC (permalink / raw)
To: Gerriko io, git
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-11 22:55 ` Thomas Guyot
@ 2022-07-12 7:12 ` Jeff King
2022-07-12 9:22 ` Thomas Guyot
0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2022-07-12 7:12 UTC (permalink / raw)
To: Thomas Guyot; +Cc: Gerriko io, git
On Mon, Jul 11, 2022 at 06:55:09PM -0400, Thomas Guyot wrote:
> 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).
This is right with one caveat: the HEAD reflog is branch agnostic. But
there is a separate reflog for each individual branch, as well.
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-12 7:12 ` Jeff King
@ 2022-07-12 9:22 ` Thomas Guyot
2022-07-12 14:23 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Guyot @ 2022-07-12 9:22 UTC (permalink / raw)
To: Jeff King; +Cc: Gerriko io, git
On 2022-07-12 03:12, Jeff King wrote:
> On Mon, Jul 11, 2022 at 06:55:09PM -0400, Thomas Guyot wrote:
>
>> 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).
> This is right with one caveat: the HEAD reflog is branch agnostic. But
> there is a separate reflog for each individual branch, as well.
Hi Jeff,
Thanks for clarifying that - I suspected it since we can do
<branch>@{<date>} although I didn't find any reference branch reflogs in
the documentation. I could've missed it... Is there a way to read a
branch reflog?
--
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-12 9:22 ` Thomas Guyot
@ 2022-07-12 14:23 ` Junio C Hamano
2022-07-12 15:18 ` Sergey Organov
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2022-07-12 14:23 UTC (permalink / raw)
To: Thomas Guyot; +Cc: Jeff King, Gerriko io, git
Thomas Guyot <tguyot@gmail.com> writes:
> Thanks for clarifying that - I suspected it since we can do
> <branch>@{<date>} although I didn't find any reference branch reflogs
> in the documentation. I could've missed it... Is there a way to read a
> branch reflog?
$ git reflog ;# lists entries of reflog of HEAD, starting at HEAD@{0}
$ git reflog HEAD ;# same
$ git reflog HEAD@{4} ;# same, starting at HEAD@{4}
$ git reflog master ;# entries of reflog of "master"
$ git reflog master@{0} ;# same
$ git reflog master@{now} ;# same, show with timestamps
$ git reflog master@{4.minutes} ;# same, starting at master@{4.minutes}
For the branch that is currently checked out, you can omit the name
when you use any of the @{...} notation, so
$ git reflog @{0}
$ git reflog @{now}
are often the easiest ways to view what you did on the current
branch.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-12 14:23 ` Junio C Hamano
@ 2022-07-12 15:18 ` Sergey Organov
2022-07-12 15:50 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Sergey Organov @ 2022-07-12 15:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Guyot, Jeff King, Gerriko io, git
Junio C Hamano <gitster@pobox.com> writes:
> Thomas Guyot <tguyot@gmail.com> writes:
>
>> Thanks for clarifying that - I suspected it since we can do
>> <branch>@{<date>} although I didn't find any reference branch reflogs
>> in the documentation. I could've missed it... Is there a way to read a
>> branch reflog?
>
> $ git reflog ;# lists entries of reflog of HEAD, starting at HEAD@{0}
> $ git reflog HEAD ;# same
> $ git reflog HEAD@{4} ;# same, starting at HEAD@{4}
> $ git reflog master ;# entries of reflog of "master"
> $ git reflog master@{0} ;# same
> $ git reflog master@{now} ;# same, show with timestamps
> $ git reflog master@{4.minutes} ;# same, starting at master@{4.minutes}
>
> For the branch that is currently checked out, you can omit the name
> when you use any of the @{...} notation, so
>
> $ git reflog @{0}
> $ git reflog @{now}
>
> are often the easiest ways to view what you did on the current
> branch.
Very handy, thanks! Would be nice to have this in EXAMPLES section of
corresponding manual page.
Honestly, I tried (admittedly not very hard) to figure how to get dates
from "git reflog" a few times, but every time I gave up, so this (along
with the --dates option turning dates output on) is not very
discoverable.
--
Sergey Organov
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-12 15:18 ` Sergey Organov
@ 2022-07-12 15:50 ` Junio C Hamano
2022-07-14 0:03 ` Thomas Guyot
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2022-07-12 15:50 UTC (permalink / raw)
To: Sergey Organov; +Cc: Thomas Guyot, Jeff King, Gerriko io, git
Sergey Organov <sorganov@gmail.com> writes:
> Very handy, thanks! Would be nice to have this in EXAMPLES section of
> corresponding manual page.
>
> Honestly, I tried (admittedly not very hard) to figure how to get dates
> from "git reflog" a few times, but every time I gave up, so this (along
> with the --dates option turning dates output on) is not very
> discoverable.
Heh, I wouldn't have bothered writing the message you are responding
to if it were documented already ;-)
Patches welcome.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why is reflog so obscure?
2022-07-12 15:50 ` Junio C Hamano
@ 2022-07-14 0:03 ` Thomas Guyot
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Guyot @ 2022-07-14 0:03 UTC (permalink / raw)
To: Junio C Hamano, Sergey Organov; +Cc: Jeff King, Gerriko io, git
On 2022-07-12 11:50, Junio C Hamano wrote:
> Sergey Organov <sorganov@gmail.com> writes:
>
>> Very handy, thanks! Would be nice to have this in EXAMPLES section of
>> corresponding manual page.
>>
>> Honestly, I tried (admittedly not very hard) to figure how to get dates
>> from "git reflog" a few times, but every time I gave up, so this (along
>> with the --dates option turning dates output on) is not very
>> discoverable.
> Heh, I wouldn't have bothered writing the message you are responding
> to if it were documented already ;-)
>
> Patches welcome.
Indeed these are great! I was thinking the same thing, I can work on a
patch shortly.
Regards,
--
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-07-14 0:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-11 21:02 Why is reflog so obscure? Gerriko io
2022-07-11 22:55 ` Thomas Guyot
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
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).