| 场景 | 误 reset、误删分支、误 amend |
|---|---|
| 定位 | git fsck --lost-found 或 git reflog |
| 接回 | git branch <名称> <哈希>;git reset --hard <哈希> |
常用示例
常用示例
git fsck --lost-found
git show <dangling-commit-hash>
git branch rescued <hash>
git reflog | head -20找回后尽快挂到分支或标签上,避免后续 gc 把对象清掉。
恢复流程:fsck --lost-found 或 reflog 定位无引用提交,git show 核对内容后用 branch/reset 接回历史。
| 场景 | 误 reset、误删分支、误 amend |
|---|---|
| 定位 | git fsck --lost-found 或 git reflog |
| 接回 | git branch <名称> <哈希>;git reset --hard <哈希> |
git fsck --lost-found
git show <dangling-commit-hash>
git branch rescued <hash>
git reflog | head -20