Aborted old git rebase and lost commits since the rebase started

半城伤御伤魂 提交于 2019-12-02 15:03:13

Check git reflog. You can walk back in time using those commit hashes as a reference in almost all cases.

I'd also physically copy the git repo directory elsewhere as a place to do preliminary testing to see what will work, that way you can mess with whatever you want without losing untracked files or getting things into a state that you can't come back from.

VonC

You should be able to get the SHA1 of your most recent commits (that disappeared after the rebase --abort) with a git reflog.

You will be able then to reset your current branch to those SHA1

# Suppose the old commit was HEAD@{2} in the ref log
git reset --hard HEAD@{2}

It is a bit like "Undoing a git reset --hard HEAD~1".

See also the "illustrated guide to recovering lost commits with Git", for other examples of recovery.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!