Undoing a git rebase

前端 未结 18 1683
孤城傲影
孤城傲影 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 03:07

    Using reflog didn't work for me.

    What worked for me was similar to as described here. Open the file in .git/logs/refs named after the branch that was rebased and find the line that contains "rebase finsihed", something like:

    5fce6b51 88552c8f Kris Leech  1329744625 +0000  rebase finished: refs/heads/integrate onto 9e460878
    

    Checkout the second commit listed on the line.

    git checkout 88552c8f
    

    Once confirmed this contained my lost changes I branched and let out a sigh of relief.

    git log
    git checkout -b lost_changes
    

提交回复
热议问题