The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the reflog ...
(最简单的方法是找到分支的头提交,就像在reflog中重新启动基础之前一样...)
git reflog
and to reset the current branch to it (with the usual caveats about being absolutely sure before reseting with the --hard
option).
(然后将当前分支重置为该分支(通常的警告是在使用--hard
选项进行重置之前必须绝对确定)。)
Suppose the old commit was HEAD@{5}
in the ref log:
(假设参考日志中的旧提交为HEAD@{5}
:)
git reset --hard HEAD@{5}
In Windows, you may need to quote the reference:
(在Windows中,您可能需要引用以下引用:)
git reset --hard "HEAD@{5}"
You can check the history of the candidate old head by just doing a git log HEAD@{5}
( Windows: git log "HEAD@{5}"
).
(您可以通过执行git log HEAD@{5}
( Windows: git log "HEAD@{5}"
)来检查候选旧头的历史git log "HEAD@{5}"
。)
If you've not disabled per branch reflogs you should be able to simply do git reflog branchname@{1}
as a rebase detaches the branch head before reattaching to the final head.
(如果尚未对每个分支引用禁用禁用,则应该可以简单地执行git reflog branchname@{1}
因为在重新附加到最终头之前,rebase会分离分支头。)
I would double check this, though as I haven't verified this recently. (我会再次检查,尽管最近还没有验证。)
Per default, all reflogs are activated for non-bare repositories:
(默认情况下,针对非裸存储库激活所有引用日志:)
[core]
logAllRefUpdates = true
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…