| 过期 | git reflog expire --expire=now --all |
|---|---|
| 清理 | git gc --prune=now |
| 恢复窗口 | 默认 reflog 保留 90 天,过期后旧提交不再受保护 |
常用示例
常用示例
git reflog -5
git reflog expire --expire=now --all
git gc --prune=now
git fsck --unreachable | head执行即失去对应恢复能力:只在确认现场不需要回退时使用,团队仓库需提前公告。
reflog 记录引用变动,是误操作的恢复通道;确认不再需要恢复时(如完成历史重写),过期 reflog 并 gc 才能让旧对象真正被回收。
| 过期 | git reflog expire --expire=now --all |
|---|---|
| 清理 | git gc --prune=now |
| 恢复窗口 | 默认 reflog 保留 90 天,过期后旧提交不再受保护 |
git reflog -5
git reflog expire --expire=now --all
git gc --prune=now
git fsck --unreachable | head