LinuxCommandLibrary

git-reflog

Record and recover reference movements

TLDR

Show reflog

$ git reflog
copy
Show reflog for branch
$ git reflog [branch]
copy
Show with timestamps
$ git reflog --date=relative
copy
Expire old entries
$ git reflog expire --expire=[90.days] --all
copy
Delete specific entry
$ git reflog delete HEAD@{2}
copy

SYNOPSIS

git reflog [command] [options]

DESCRIPTION

git reflog records when refs (like HEAD and branch tips) are updated, providing a safety net for recovering lost commits. After accidental resets, rebases, or branch deletions, the reflog shows where refs previously pointed, allowing recovery of otherwise unreachable commits.
Entries in the reflog expire after a configurable period (default 90 days). The reflog is local only and is not shared between repositories.

PARAMETERS

show REF

Show reflog for ref (default).
expire
Prune old reflog entries.
delete
Delete specific entries.
--all
Process all refs.
--expire TIME
Expire older than time.
--date FORMAT
Date format.
-n NUM
Limit entries shown.
--help
Display help information.

CAVEATS

Local only, not pushed. Entries expire (default 90 days). Won't help after gc removes objects.

HISTORY

git reflog is a core Git safety feature, providing local history of ref movements to enable recovery from destructive operations.

SEE ALSO

git-log(1), git-reset(1), git-gc(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community