完成功能分支后,在 git rebase -i
期间,我不小心删除了所有提交。我不完全确定,但我怀疑我没有压缩我的提交,而是用提交消息替换了整个条目。
http://shafiulazam.com/gitbook/4_interactive_rebasing.html说:
The last useful thing that interactive rebase can do is drop commits for you. If instead of choosing 'pick', 'squash' or 'edit' for the commit line, you simply remove the line, it will remove the commit from the history.
我的问题是:有没有办法恢复/撤消此操作?
最佳答案
如果你刚刚做了rebase,你可以试试mentioned here :
git reset --hard ORIG_HEAD
ORIG_HEAD
is previous state ofHEAD
, set by commands that have possibly dangerous behavior, to be easy to revert them.
It is less useful now that Git has reflog:HEAD@{1}
is roughly equivalent toORIG_HEAD
(HEAD@{1}
is always last value ofHEAD
,ORIG_HEAD
is last value ofHEAD
before dangerous operation).
如果您自 rebase 后执行了一些操作,reflog can still help .
关于git - 还原交互式 git rebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5375066/