32

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,782
  • 7
  • 45
  • 72
Aishwar
  • 9,284
  • 10
  • 59
  • 80

1 Answers1

48

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,546
  • 4
  • 30
  • 60
Christoph
  • 26,519
  • 28
  • 95
  • 133