Reflog
一句话解释
reflog 是局部 log 的每个 HEAD and 分支指针 movement — 它是 你的 safety net for recovering "lost" 提交.
用大白话说
The reflog (reference log) records every time HEAD or a branch pointer moves — every commit, checkout, reset, rebase, and merge. It is a local-only history of where your pointers have been.
reflog 是your safety net。 If you accidentally git reset --困难 and lose commits, they are still in the reflog. You can find the lost commit hash with git reflog and recover it with git reset --困难 <hash>.
Reflog entries expire after a configurable period (default 90 days for unreachable commits, 30 days for reachable). Until then, commits referenced only by the reflog are not garbage collected. This makes the reflog a powerful recovery tool for undoing mistakes.
示例
# View the reflog
git reflog
# a1b2c3d HEAD@{0}: reset: moving to HEAD~1
# e5f6g7h HEAD@{1}: commit: Add feature
# Recover a lost commit
git reset --hard e5f6g7hreflog shows 所有指针 movements. Use 它到 recover lost 提交.
相关术语
相关资源
相关课程
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。