28

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!

LanguagesNamedAfterCofee
  • 5,532
  • 7
  • 42
  • 72
Aishwar
  • 8,754
  • 9
  • 57
  • 77

1 Answers1

45

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
kleinfreund
  • 6,144
  • 4
  • 29
  • 58
Christoph
  • 23,839
  • 25
  • 91
  • 129