恢复交互式git rebase [英] Reverting an interactive git rebase
问题描述
完成一个功能分支后,在 git rebase -i
过程中,我意外地删除了所有提交。我不完全确定,但我怀疑,我没有压缩提交,而是用提交消息替换了整个条目。
After completing a feature branch, during a git rebase -i
I accidentally removed all my commits. I'm not completely sure but I suspect that instead of squashing my commits, I replaced the entire entry with a commit message.
http://shafiulazam.com/gitbook/4_interactive_rebasing.html 说:
交互式
rebase可以做的最后一件有用的事是为您提交提交。
如果不是为提交
行选择'pick',
'squash'或'edit',只需删除该行,它将
从$
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.
我的问题是:有没有办法恢复/取消这个?
My question is: is there a way to revert/undo this?
推荐答案
如果您刚刚完成了rebase,您可以尝试:
If you have just done the rebase, you can try as mentioned here:
git reset --hard ORIG_HEAD
as JakubNarębski 详细信息:
ORIG_HEAD
是之前的状态HEAD
,由可能具有危险行为的命令设置,以便于恢复它们。
现在,Git ha s引用日志:HEAD @ {1}
大致相当于ORIG_HEAD
(HEAD @ {1 }
始终是HEAD的最后一个值,
,
ORIG_HEAD
是<$ c $的最后一个值如果你已经执行了一些操作,因为
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).
em> rebase, reflog 仍然可以帮助。
If you have executed some operations since the rebase, the reflog can still help.
这篇关于恢复交互式git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!