Aborted old git rebase and lost commits since the rebase started

前端 未结 2 1779
野趣味
野趣味 2021-01-30 10:08

Crap! About a week ago, I was rebasing some commits while trying to clean up my repository, and apparently I didn\'t actually finish it. Today, a week and several commits later,

2条回答
  •  执念已碎
    2021-01-30 10:57

    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.

提交回复
热议问题