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!
Yes, you can rebase more than once. After rebasing, you get a fresh set of commits. These commits are exactly like all other commits and hold no record of having been rebased.
First of all, you must understand that Git rebase is a destructive operation. Git generates new commits based on your previous commits onto the target branch. Your former commits will, therefore, be destroyed. Basically, you rewrite your Git history!
You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With