恢复交互式git rebase [英] Reverting an interactive git rebase

查看:106
本文介绍了恢复交互式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 of HEAD, 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 to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation).

em> rebase, reflog 仍然可以帮助

If you have executed some operations since the rebase, the reflog can still help.

这篇关于恢复交互式git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆