Undoing a git rebase

前端 未结 18 1679
孤城傲影
孤城傲影 2020-11-22 02:41

Does anybody know how to easily undo a git rebase?

The only way that comes to mind is to go at it manually:

  • git checkout the commit parent to both of t
18条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 02:55

    If you don't want to do a hard reset...

    You can checkout the commit from the reflog, and then save it as a new branch:

    git reflog
    

    Find the commit just before you started rebasing. You may need to scroll further down to find it (press Enter or PageDown). Take note of the HEAD number and replace 57:

    git checkout HEAD@{57}
    

    Review the branch/commits, and if it's correct then create a new branch using this HEAD:

    git checkout -b new_branch_name
    

提交回复
热议问题