git reflog

Manage reference log information

Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository. Reference logs are completely local and aren't included in pushes, fetches or clones.

Reflogs are useful in various Git commands, to specify the old value of a reference. For example, HEAD@{2} means "where HEAD used to be two moves ago", master@{one.week.ago} means "where master used to point to one week ago in this local repository", and so on.

This command manages the information recorded in the reflogs.

The show subcommand (which is also the default, in the absence of any subcommands) shows the log of the reference provided in the command-line (or HEAD, by default). The reflog covers all recent actions, and in addition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit --pretty=oneline.

The expire subcommand prunes older reflog entries. Entries older than expire time, or entries older than expire-unreachable time and not reachable from the current tip, are removed from the reflog. This is typically not used directly by end users.

The delete subcommand deletes single entries from the reflog. Its argument must be an exact entry (e.g. git reflog delete master@{2}). This subcommand is also typically not used directly by end users.

The exists subcommand checks whether a ref has a reflog. It exits with zero status if the reflog exists, and non-zero status if it does not.

How-tos using git reflog

Last modified on November 30, 2021.

Can't find a solution to your git problem?

Contact us on githint@githint.com and we will add the solution to the site