Skip to contentSkip to conversation

git-reflog.txt: add an EXAMPLES section

PATCH In review Elia Pinto 4 participants 7 messages Oct 3, 2022 Documentation

lore
Share & tools
lore

Elia Pinto

author
#0 lore raw

PATCH 1/1 git-reflog.txt: add an EXAMPLES section

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

---
 Documentation/git-reflog.txt | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
Documentation/git-reflog.txt +42 -0
index 70791b9fd8..5bbd5958fe 100644
@@ -96,6 +96,48 @@ them.
 --verbose::
 	Print extra information on screen.
 
+EXAMPLES
+--------
+
+`git reflog`::
+	Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
+
+`git reflog HEAD`::
+	The same.
+
+`git reflog show HEAD`::
+	The same.
+
+`git reflog HEAD@{4}`::
+	The same, starting at the 4th prior value of HEAD.
+
+`git reflog master`::
+	Lists entries of reflog of `master`.
+
+`git reflog master@{0}`::
+	The same.
+
+`git reflog master@{now}`::
+	The same, show with timestamp.
+
+`git reflog master@{4.minutes}`::
+	The same, starting at master, 4 minutes ago.
+
+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
+
+SEE ALSO
+--------
+linkgit:gitrevisions[7],
+linkgit:git-log[1]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
Signature · 1 line
2.37.3
#1 lore raw
Quoted 5 lines · Elia Pinto

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

I think it can be valuable to have an EXAMPLES section, but:

Quoted 26 lines
Documentation/git-reflog.txt +26 -0
+EXAMPLES
+--------
+
+`git reflog`::
+	Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
+
+`git reflog HEAD`::
+	The same.
+
+`git reflog show HEAD`::
+	The same.
+
+`git reflog HEAD@{4}`::
+	The same, starting at the 4th prior value of HEAD.
+
+`git reflog master`::
+	Lists entries of reflog of `master`.
+
+`git reflog master@{0}`::
+	The same.
+
+`git reflog master@{now}`::
+	The same, show with timestamp.
+
+`git reflog master@{4.minutes}`::
+	The same, starting at master, 4 minutes ago.

Documentation/git-reflog.txt them. · line 134

Quoted 10 lines
Documentation/git-reflog.txt +10 -0
+
+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

Most of this really just seems to be duplicating "SPECIFYING REVISIONS", and some of it such as "show with timestamp" is ambiguous/misleading. If I didn't know how it worked I'd think that it might affect the output itself (maybe showing times "relative to now"), but it's just gitrevisions syntax.

Documentation/git-reflog.txt them. · line 139

Quoted 4 lines
Documentation/git-reflog.txt +4 -0
+SEE ALSO
+--------
+linkgit:gitrevisions[7],
+linkgit:git-log[1]

Likewise "SEE ALSO" sections can be really valuable, but they're really for "now that you've read the above, maybe this is also useful". It's not a "SEE STUFF YOU SAW BEFORE" :)

In this case we link to these in the first and third paragraphs of the DESCRIPTION section (respectively), since explaining the revision syntax etc. is really core to understanding how this command works.

The "SEE ALSO" section is really more for stuff like (in this case) 'git-fsck', 'git-filter-branch', 'git-rev-list' or 'git-stash'. All of those commansd have some direct interaction with the 'reflog', but are not mentioned in the main prose.

author
#2 lore raw

Il giorno lun 3 ott 2022 alle ore 11:27 Ævar Arnfjörð Bjarmason <[email protected]> ha scritto:

Quoted 46 lines · Elia Pinto
Quoted 6 lines

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

I think it can be valuable to have an EXAMPLES section, but:

Quoted 34 lines
Documentation/git-reflog.txt +34 -0
+EXAMPLES
+--------
+
+`git reflog`::
+     Lists entries of reflog of HEAD, starting at `HEAD@{0}`.
+
+`git reflog HEAD`::
+     The same.
+
+`git reflog show HEAD`::
+     The same.
+
+`git reflog HEAD@{4}`::
+     The same, starting at the 4th prior value of HEAD.
+
+`git reflog master`::
+     Lists entries of reflog of `master`.
+
+`git reflog master@{0}`::
+     The same.
+
+`git reflog master@{now}`::
+     The same, show with timestamp.
+
+`git reflog master@{4.minutes}`::
+     The same, starting at master, 4 minutes ago.
+
+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}`
+
Quoted 8 lines

Documentation/git-reflog.txt them. · line 134

Quoted 2 lines
Documentation/git-reflog.txt +2 -0
+are often the easiest ways to view what you did on the current
+branch

Most of this really just seems to be duplicating "SPECIFYING REVISIONS", and some of it such as "show with timestamp" is ambiguous/misleading. If I didn't know how it worked I'd think that it might affect the output itself (maybe showing times "relative to now"), but it's just gitrevisions syntax.

Thanks a lot, in the meantime.

The examples included are based on an email exchange done here between a user and a git developer, maybe Junio, I don't remember. The user found the explanation useful, as he had a hard time understanding how git-reflog worked with branches. I agree that better could be done, for example by entering how to recover lost commits, but that was not the goal at the moment. Later this is something that it is always possible to do. It is also true that the examples in practice show what should already be known with gitrevisions however obviously many users cannot find the link between the two, I must imagine

Quoted 10 lines

Documentation/git-reflog.txt them. · line 139

Quoted 5 lines
Documentation/git-reflog.txt +4 -0
+SEE ALSO
+--------
+linkgit:gitrevisions[7],
+linkgit:git-log[1]

Likewise "SEE ALSO" sections can be really valuable, but they're really for "now that you've read the above, maybe this is also useful". It's not a "SEE STUFF YOU SAW BEFORE" :)

Quoted 9 lines

In this case we link to these in the first and third paragraphs of the DESCRIPTION section (respectively), since explaining the revision syntax etc. is really core to understanding how this command works.

The "SEE ALSO" section is really more for stuff like (in this case) 'git-fsck', 'git-filter-branch', 'git-rev-list' or 'git-stash'. All of those commansd have some direct interaction with the 'reflog', but are not mentioned in the main prose.

Better not to put a "SEE ALSO" then? I personally don't know

Quoted 4 lines
#3 lore raw
Quoted 9 lines · Elia Pinto

The examples included are based on an email exchange done here between a user and a git developer, maybe Junio, I don't remember. The user found the explanation useful, as he had a hard time understanding how git-reflog worked with branches. I agree that better could be done, for example by entering how to recover lost commits, but that was not the goal at the moment. Later this is something that it is always possible to do. It is also true that the examples in practice show what should already be known with gitrevisions however obviously many users cannot find the link between the two, I must imagine

Geez. I did find the examples, especially the use of "4" as a random number pulled out of thin air, vaguely familiar. You seem to mean https://lore.kernel.org/git/[email protected]/

#4 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 8 lines · Ævar Arnfjörð Bjarmason
Quoted 5 lines · Elia Pinto

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

Quoted 4 lines

I think it can be valuable to have an EXAMPLES section, but:
...
Most of this really just seems to be duplicating "SPECIFYING REVISIONS", and some of it such as "show with timestamp" is ambiguous/misleading.

It would become immediately clear what these phrases want to say, when the reader runs "git reflog @{0}" and "git reflog @{now}" while reading the document. I am not sure if the description is ambiguous or misleading to those who haven't seen any reflog output, especially the timestamped ones. Perhaps some sample output in the documentation would help, do you think?

    $ git reflog -2 HEAD@{now}
    ce17cbfa2b HEAD@{Mon Oct 3 09:07:30 2022 -0700}: checkout: moving...
    ce17cbfa2b HEAD@{Mon Oct 3 09:07:14 2022 -0700}: am: ssh signing...
    $ git reflog -2 HEAD@{0}
    ce17cbfa2b HEAD@{0}: checkout: moving...
    ce17cbfa2b HEAD@{1}: am: ssh signing...

I would freely admit that this is one of my least favourite part of Git UI that allows what comes inside @{} as parameter to "git reflog" affect both the starting point (e.g. @{2.days} omits the activities of the past 48 hours) and the format of the output. The taste of the design is bad, but it is what we ended up with.

Quoted 9 lines

Documentation/git-reflog.txt them. · line 139

Quoted 4 lines
Documentation/git-reflog.txt +4 -0
+SEE ALSO
+--------
+linkgit:gitrevisions[7],
+linkgit:git-log[1]

Likewise "SEE ALSO" sections can be really valuable, but they're really for "now that you've read the above, maybe this is also useful". It's not a "SEE STUFF YOU SAW BEFORE" :)

Quoted 3 lines

In this case we link to these in the first and third paragraphs of the DESCRIPTION section (respectively), since explaining the revision syntax etc. is really core to understanding how this command works.

I do not know about that.

Only the part of the revision syntax that refers to the tip of a ref works as input for "git reflog". IOW, "git reflog seen^2~4" does not work. I do not think the knowledge of revision syntax helps understanding how to operate the command that much because of the above. I agree with you that it is dubious if it is a good idea to list gitrevisions[7] here, but for an entirely different reason.

On the other hand, git-log[1] might not be a bad thing to refer to, in order to learn that you can say something like

    git reflog --pretty=short --stat @{now}

Thanks for a review.

#5 lore raw
In reply to Elia Pinto
Quoted 6 lines · Elia Pinto

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

Better say "Add git-reflog usage examples to the man page." Also, shouldn't "SEE ALSO" additions be split from this patch?

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#6 lore raw
Quoted 9 lines · Bagas Sanjaya
Quoted 6 lines · Elia Pinto

This commit adds an "EXAMPLES" section to the git reflog man page. This new section currently provides examples of using git reflog with branches, for which doubts often exist. In this commit we also add a "SEE ALSO" section which refers to further information on git commands or documentation referenced in the git reflog man page.

Better say "Add git-reflog usage examples to the man page."

Thanks, indeed.

Quoted 1 line

Also, shouldn't "SEE ALSO" additions be split from this patch?

I think they are better together. The overall theme is to help readers of that one documentation page, and 80% of the effort of this step is spent on adding an EXAMPLES section, while the rest goes to SEE ALSO.

Thanks.