The reflog Command

Manage reflog information

Usage

libra reflog <SUBCOMMAND> [OPTIONS]

Subcommands

  • show Show the reflog history. This is the default action if no subcommand is provided.

  • delete Delete specific entries from the reflog.

  • exists Check if a ref has a reflog.

Description

The libra reflog command is used to manage the log of reference changes. It tracks when the tips of branches and other references were updated in the local repository. It's a powerful tool for recovering lost work and undoing mistakes, acting as a "safety net" for your repository.

  • To show the history of HEAD, simply run: libra reflog or libra reflog show

  • To show the history of a specific branch: libra reflog show <branch-name>

  • To delete the second-to-last entry of the HEAD reflog: libra reflog delete HEAD@1

Options (reflog show)

  • <ref> The reference to show the log for (e.g., HEAD, main, origin/main). Defaults to HEAD.

  • --pretty=<format> Format the output of the reflog entries. Supported formats are:

    oneline: The default, compact format (<hash> <selector>: <subject>).

    short: Shows commit hash, author, and subject.

    medium: Shows commit hash, author, date, and full message.

    full: Shows author and committer information.

  • -h, --help Print help for the reflog command or a specific subcommand.

Options (reflog delete)

<entry>... One or more reflog entries to delete (e.g., HEAD@2, main@5). This argument is required.

Note:

The reflog command is indispensable for recovering from situations where you might think you've lost work, such as after a faulty reset or rebase. It tracks local movements of references, so it won't be available in bare or freshly cloned repositories until some actions are performed. Refs https://git-scm.com/docs/git-reflog for more information.