NAME

git-reflog - Manage reflog information

SYNOPSIS

  1. git reflog <subcommand> <options>

DESCRIPTION

The command takes various subcommands, and different optionsdepending on the subcommand:

  1. git reflog [show] [log-options] [<ref>]
  2. git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
  3. [--rewrite] [--updateref] [--stale-fix]
  4. [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>…​]
  5. git reflog delete [--rewrite] [--updateref]
  6. [--dry-run | -n] [--verbose] ref@{specifier}…​
  7. git reflog exists <ref>

Reference logs, or "reflogs", record when the tips of branches andother references were updated in the local repository. Reflogs areuseful in various Git commands, to specify the old value of areference. For example, HEAD@{2} means "where HEAD used to be twomoves ago", master@{one.week.ago} means "where master used to pointto one week ago in this local repository", and so on. Seegitrevisions[7] for more details.

This command manages the information recorded in the reflogs.

The "show" subcommand (which is also the default, in the absence ofany subcommands) shows the log of the reference provided in thecommand-line (or HEAD, by default). The reflog covers all recentactions, and in addition the HEAD reflog records branch switching.git reflog show is an alias for git log -g —abbrev-commit—pretty=oneline; see git-log[1] for more information.

The "expire" subcommand prunes older reflog entries. Entries olderthan expire time, or entries older than expire-unreachable timeand not reachable from the current tip, are removed from the reflog.This is typically not used directly by end users — instead, seegit-gc[1].

The "delete" subcommand deletes single entries from the reflog. Itsargument must be an exact entry (e.g. "git reflog deletemaster@{2}"). This subcommand is also typically not used directly byend users.

The "exists" subcommand checks whether a ref has a reflog. It exitswith zero status if the reflog exists, and non-zero status if it doesnot.

OPTIONS

Options for show

git reflog show accepts any of the options accepted by git log.

Options for expire

  • —all
  • Process the reflogs of all references.

  • —single-worktree

  • By default when —all is specified, reflogs from all workingtrees are processed. This option limits the processing to reflogsfrom the current working tree only.

  • —expire=

  • Prune entries older than the specified time. If this option isnot specified, the expiration time is taken from theconfiguration setting gc.reflogExpire, which in turndefaults to 90 days. —expire=all prunes entries regardlessof their age; —expire=never turns off pruning of reachableentries (but see —expire-unreachable).

  • —expire-unreachable=

  • Prune entries older than <time> that are not reachable fromthe current tip of the branch. If this option is notspecified, the expiration time is taken from the configurationsetting gc.reflogExpireUnreachable, which in turn defaultsto 30 days. —expire-unreachable=all prunes unreachableentries regardless of their age; —expire-unreachable=neverturns off early pruning of unreachable entries (but see—expire).

  • —updateref

  • Update the reference to the value of the top reflog entry (i.e.@{0}) if the previous top entry was pruned. (Thisoption is ignored for symbolic references.)

  • —rewrite

  • If a reflog entry’s predecessor is pruned, adjust its "old"SHA-1 to be equal to the "new" SHA-1 field of the entry thatnow precedes it.

  • —stale-fix

  • Prune any reflog entries that point to "broken commits". Abroken commit is a commit that is not reachable from any ofthe reference tips and that refers, directly or indirectly, toa missing commit, tree, or blob object.

This computation involves traversing all the reachable objects, i.e. ithas the same cost as git prune. It is primarily intended to fixcorruption caused by garbage collecting using older versions of Git,which didn’t protect objects referred to by reflogs.

  • -n
  • —dry-run
  • Do not actually prune any entries; just show what would havebeen pruned.

  • —verbose

  • Print extra information on screen.

Options for delete

git reflog delete accepts options —updateref, —rewrite, -n,—dry-run, and —verbose, with the same meanings as when they areused with expire.

GIT

Part of the git[1] suite