← 返回命令列表

Linux command

git-reflog 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show reflog

git reflog

Show reflog for branch

git reflog [branch]

Show with timestamps

git reflog --date=relative

Expire old entries

git reflog expire --expire=[90.days] --all

Delete specific entry

git reflog delete HEAD@{2}

说明

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.

参数

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.

FAQ

What is the git-reflog command used for?

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.

How do I run a basic git-reflog example?

Run `git reflog` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does show _REF_ do in git-reflog?

Show reflog for ref (default).