{"thread":{"id":"58138","subject":"Why is reflog so obscure?","startedAt":"2022-07-11T21:02:34Z","lastAt":"2022-07-14T00:03:59Z","messageCount":8,"participants":["Gerriko io","Thomas Guyot","Jeff King","Junio C Hamano","Sergey Organov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"458820","messageId":"CALF=2ANoq1eL-RqK_dLaVThoxbvfhzgPJXFHyD1kX8CFCPx3XA@mail.gmail.com","threadId":"58138","inReplyTo":null,"subject":"Why is reflog so obscure?","fromName":"Gerriko io","fromEmail":"gerriko.iot@gmail.com","sentAt":"2022-07-11T21:02:19Z","receivedAt":"2022-07-11T21:02:34Z","isPatch":false,"sender":{"key":"gerriko.iot@gmail.com","avatar":null},"body":"I am trying to make sense of reflog as I need to know this to use\nrevert and reset properly.\n\nI cannot find the most basic information in the git documentation or online.\n\nSurely the most basic question is whether the reflog is sequential or\njust random logs or whether it is in time ascending or descending\norder.\n\nWithout this information I am left baffled and have to guess what this\nline means out of the many:\n\na0bbd34 (HEAD -> master, origin/master, origin/main)\nrefs/remotes/origin/main@{0}: update by push\n\nWhy does it have to be so obscure?\n"},{"id":"458833","messageId":"f0bb8ee8-9b38-45a7-a54b-24cf245bb3c8@gmail.com","threadId":"58138","inReplyTo":"CALF=2ANoq1eL-RqK_dLaVThoxbvfhzgPJXFHyD1kX8CFCPx3XA@mail.gmail.com","subject":"Re: Why is reflog so obscure?","fromName":"Thomas Guyot","fromEmail":"tguyot@gmail.com","sentAt":"2022-07-11T22:55:09Z","receivedAt":"2022-07-11T22:55:15Z","isPatch":false,"sender":{"key":"tguyot@gmail.com","avatar":"https://avatars.githubusercontent.com/u/403890?v=4"},"body":"On 2022-07-11 17:02, Gerriko io wrote:\n> I am trying to make sense of reflog as I need to know this to use\n> revert and reset properly.\n>\n> I cannot find the most basic information in the git documentation or online.\n>\n> Surely the most basic question is whether the reflog is sequential or\n> just random logs or whether it is in time ascending or descending\n> order.\n>\n> Without this information I am left baffled and have to guess what this\n> line means out of the many:\n>\n> a0bbd34 (HEAD -> master, origin/master, origin/main)\n> refs/remotes/origin/main@{0}: update by push\n>\n> Why does it have to be so obscure?\n\nHi,\n\nThe reflog is simply a log of where you've been, in descending order \n(latest entry first), and is branch agnostic. It show every commit \nyou've been on from latest to oldest, and each entry can be heads, tags, \nor detached commits. Some operations like rebase may even generate \nmultiple entries if it's done in multiple steps (ex conflicts resolution).\n\nI believe its main uses are to delay garbage collect (which happens only \nafter entries have expired form the reflog) and to allow refs selection \nusing @{date} and @{nth} specifiers (see git-rev-parse, and note @{date} \nis not the commit date but rather the reflog date!)... And it's \nobviously quite handy to recover a dropped/rewritten ref if you realize \nyou need to undo what you've done.\n\nSince the date is recorded for each entry you can also display it using \nthe --date=<format> option. For example to display reflog entries in \nlocal human-readable time, use:\n\ngit reflog --date=local\n\nThe git-reflog log display options are mostly the same as git-log and \ndocumented in git-log's manpage.\n\nRegards,\n\n--\nThomas\n"},{"id":"458858","messageId":"Ys0e9MxIWQj/pVXx@coredump.intra.peff.net","threadId":"58138","inReplyTo":"f0bb8ee8-9b38-45a7-a54b-24cf245bb3c8@gmail.com","subject":"Re: Why is reflog so obscure?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-07-12T07:12:52Z","receivedAt":"2022-07-12T07:12:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 11, 2022 at 06:55:09PM -0400, Thomas Guyot wrote:\n\n> The reflog is simply a log of where you've been, in descending order (latest\n> entry first), and is branch agnostic. It show every commit you've been on\n> from latest to oldest, and each entry can be heads, tags, or detached\n> commits. Some operations like rebase may even generate multiple entries if\n> it's done in multiple steps (ex conflicts resolution).\n\nThis is right with one caveat: the HEAD reflog is branch agnostic. But\nthere is a separate reflog for each individual branch, as well.\n\n-Peff\n"},{"id":"458866","messageId":"a8d2a61d-b86f-9b89-6391-36c58c390a12@gmail.com","threadId":"58138","inReplyTo":"Ys0e9MxIWQj/pVXx@coredump.intra.peff.net","subject":"Re: Why is reflog so obscure?","fromName":"Thomas Guyot","fromEmail":"tguyot@gmail.com","sentAt":"2022-07-12T09:22:24Z","receivedAt":"2022-07-12T09:22:32Z","isPatch":false,"sender":{"key":"tguyot@gmail.com","avatar":"https://avatars.githubusercontent.com/u/403890?v=4"},"body":"On 2022-07-12 03:12, Jeff King wrote:\n> On Mon, Jul 11, 2022 at 06:55:09PM -0400, Thomas Guyot wrote:\n>\n>> The reflog is simply a log of where you've been, in descending order (latest\n>> entry first), and is branch agnostic. It show every commit you've been on\n>> from latest to oldest, and each entry can be heads, tags, or detached\n>> commits. Some operations like rebase may even generate multiple entries if\n>> it's done in multiple steps (ex conflicts resolution).\n> This is right with one caveat: the HEAD reflog is branch agnostic. But\n> there is a separate reflog for each individual branch, as well.\n\nHi Jeff,\n\nThanks for clarifying that - I suspected it since we can do \n<branch>@{<date>} although I didn't find any reference branch reflogs in \nthe documentation. I could've missed it... Is there a way to read a \nbranch reflog?\n\n--\nThomas\n"},{"id":"458890","messageId":"xmqqo7xuif46.fsf@gitster.g","threadId":"58138","inReplyTo":"a8d2a61d-b86f-9b89-6391-36c58c390a12@gmail.com","subject":"Re: Why is reflog so obscure?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-12T14:23:53Z","receivedAt":"2022-07-12T14:23:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Guyot <tguyot@gmail.com> writes:\n\n> Thanks for clarifying that - I suspected it since we can do\n> <branch>@{<date>} although I didn't find any reference branch reflogs\n> in the documentation. I could've missed it... Is there a way to read a \n> branch reflog?\n\n    $ git reflog ;# lists entries of reflog of HEAD, starting at HEAD@{0}\n    $ git reflog HEAD ;# same\n    $ git reflog HEAD@{4} ;# same, starting at HEAD@{4}\n    $ git reflog master ;# entries of reflog of \"master\"\n    $ git reflog master@{0} ;# same\n    $ git reflog master@{now} ;# same, show with timestamps\n    $ git reflog master@{4.minutes} ;# same, starting at master@{4.minutes}\n\nFor the branch that is currently checked out, you can omit the name\nwhen you use any of the @{...} notation, so \n\n    $ git reflog @{0}\n    $ git reflog @{now}\n\nare often the easiest ways to view what you did on the current\nbranch.\n"},{"id":"458893","messageId":"87ilo2we9o.fsf@osv.gnss.ru","threadId":"58138","inReplyTo":"xmqqo7xuif46.fsf@gitster.g","subject":"Re: Why is reflog so obscure?","fromName":"Sergey Organov","fromEmail":"sorganov@gmail.com","sentAt":"2022-07-12T15:18:27Z","receivedAt":"2022-07-12T15:21:35Z","isPatch":false,"sender":{"key":"sorganov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8501568?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thomas Guyot <tguyot@gmail.com> writes:\n>\n>> Thanks for clarifying that - I suspected it since we can do\n>> <branch>@{<date>} although I didn't find any reference branch reflogs\n>> in the documentation. I could've missed it... Is there a way to read a \n>> branch reflog?\n>\n>     $ git reflog ;# lists entries of reflog of HEAD, starting at HEAD@{0}\n>     $ git reflog HEAD ;# same\n>     $ git reflog HEAD@{4} ;# same, starting at HEAD@{4}\n>     $ git reflog master ;# entries of reflog of \"master\"\n>     $ git reflog master@{0} ;# same\n>     $ git reflog master@{now} ;# same, show with timestamps\n>     $ git reflog master@{4.minutes} ;# same, starting at master@{4.minutes}\n>\n> For the branch that is currently checked out, you can omit the name\n> when you use any of the @{...} notation, so \n>\n>     $ git reflog @{0}\n>     $ git reflog @{now}\n>\n> are often the easiest ways to view what you did on the current\n> branch.\n\nVery handy, thanks! Would be nice to have this in EXAMPLES section of\ncorresponding manual page.\n\nHonestly, I tried (admittedly not very hard) to figure how to get dates\nfrom \"git reflog\" a few times, but every time I gave up, so this (along\nwith the --dates option turning dates output on) is not very\ndiscoverable.\n\n-- \nSergey Organov\n"},{"id":"458895","messageId":"xmqq4jzmib3n.fsf@gitster.g","threadId":"58138","inReplyTo":"87ilo2we9o.fsf@osv.gnss.ru","subject":"Re: Why is reflog so obscure?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-07-12T15:50:36Z","receivedAt":"2022-07-12T15:50:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sergey Organov <sorganov@gmail.com> writes:\n\n> Very handy, thanks! Would be nice to have this in EXAMPLES section of\n> corresponding manual page.\n>\n> Honestly, I tried (admittedly not very hard) to figure how to get dates\n> from \"git reflog\" a few times, but every time I gave up, so this (along\n> with the --dates option turning dates output on) is not very\n> discoverable.\n\nHeh, I wouldn't have bothered writing the message you are responding\nto if it were documented already ;-)\n\nPatches welcome.\n"},{"id":"459027","messageId":"c12c14a9-9948-a47c-35a0-869f95d95bb9@gmail.com","threadId":"58138","inReplyTo":"xmqq4jzmib3n.fsf@gitster.g","subject":"Re: Why is reflog so obscure?","fromName":"Thomas Guyot","fromEmail":"tguyot@gmail.com","sentAt":"2022-07-14T00:03:53Z","receivedAt":"2022-07-14T00:03:59Z","isPatch":false,"sender":{"key":"tguyot@gmail.com","avatar":"https://avatars.githubusercontent.com/u/403890?v=4"},"body":"On 2022-07-12 11:50, Junio C Hamano wrote:\n> Sergey Organov <sorganov@gmail.com> writes:\n>\n>> Very handy, thanks! Would be nice to have this in EXAMPLES section of\n>> corresponding manual page.\n>>\n>> Honestly, I tried (admittedly not very hard) to figure how to get dates\n>> from \"git reflog\" a few times, but every time I gave up, so this (along\n>> with the --dates option turning dates output on) is not very\n>> discoverable.\n> Heh, I wouldn't have bothered writing the message you are responding\n> to if it were documented already ;-)\n>\n> Patches welcome.\n\nIndeed these are great! I was thinking the same thing, I can work on a \npatch shortly.\n\nRegards,\n\n--\nThomas\n\n"}]}