Skip to content

reflog: show the current branch by default - #2469

Draft
HaraldNordgren wants to merge 5 commits into
git:masterfrom
HaraldNordgren:reflog-current-branch
Draft

HaraldNordgren wants to merge 5 commits into
git:masterfrom
HaraldNordgren:reflog-current-branch

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Make "git reflog" show the reflog of the current branch by default, the same as "git reflog @{0}", and label those entries with the short branch name, e.g. "topic@{0}". With a detached HEAD it still shows the HEAD reflog.

@gitgitgadget-git

Copy link
Copy Markdown

There is an issue in commit 14ccf1b:
reflog-walk: show the current branch by its short name for @{0}

  • Commit not signed off

@gitgitgadget-git

Copy link
Copy Markdown

There is an issue in commit aec1797:
reflog: show the current branch by default

  • Commit not signed off

"git reflog @{0}" shows the reflog of the current branch, but spells
out its full refname on every line:

    47374e9 refs/heads/topic@{0}: commit: three
    3cf990e refs/heads/topic@{1}: branch: Created from HEAD

"git reflog topic" and "git reflog @{-1}" label the same entries
"topic@{0}" and so on. Do the same for @{0}. When the short name is
ambiguous, enough of the refname is kept to tell it apart, e.g.
"heads/topic@{0}" when there is also a tag "topic".

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
"git reflog" shows the HEAD reflog, which mixes the history of every
branch that was checked out with each branch switch and every step of
a rebase. To find an earlier state of the branch you are on, its own
reflog is easier to read, with one entry per change to it, e.g. a
single "rebase (finish)" entry for a whole rebase.

Show the reflog of the current branch when no ref is given, the same
as "git reflog @{0}". When HEAD is detached, this is the HEAD reflog,
and "git reflog HEAD" shows the HEAD reflog in any case.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
After a rebase, the reflogs spell out the full refname of the rebased
branch:

    topic@{0}: rebase (finish): refs/heads/topic onto <commit>
    HEAD@{0}: rebase (finish): returning to refs/heads/topic

Other reflog entries use short names, e.g. "checkout: moving from
main to topic" and "branch: Created from upstream/master". Write the
short branch name in the "finish" and "abort" entries too.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Renaming or copying a branch spells out both full refnames in the
reflog:

    HEAD@{0}: Branch: renamed refs/heads/old to refs/heads/new

Write the short branch names, the same as the other reflog entries
about branches, e.g. "checkout: moving from main to topic".

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Reflog entries written by older versions of Git spell out the full
refnames of branches:

    topic@{3}: rebase (finish): refs/heads/topic onto <commit>

Newer entries name them by their short names. Strip "refs/heads/"
from the messages when showing them, so that old and new entries
read the same.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
@taahol

taahol commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

0d0925ef1a (reflog-walk: show the current branch by its short name for @{0}, 2026-10-27)

Please mention in the commit message that it works quite nicely also with @{now}.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants