Search code examples
gitversion-controlrebasegit-rebase

Did i just destroy my work by incorrectly using git rebase


I executed the following line:

git rebase -i dev --onto master 

I figured this would cut my dev branch and paste it on top of my master branch. And the -i would let me collapse the changesets.

But when it brought up the editor, I did not see any of the changesets. All I saw was "noop". So I just exited it. And then I look at my git history, all my changes are gone. My dev branch is at the same place my master is at!

Can some one help me recover? Thanks!


Solution

  • Git makes it hard to lose work.

    Run:

    git reflog
    

    Than look for the commit that was just before the rebase

    Then check it out

    git checkout <sha>
    

    Look around, is it the version you wanted to recover?

    If so, create a branch here

    git checkout -b mybranch