Recover after git rebase --abort

2019-07-17 05:11发布

问题:

I started a git rebase in my repository a day ago and never finished it. I forgot about and did a lot of modifications while I was still in the rebase. Today I accidentally did a git rebase --abort without putting those modifications in a commit. Now it looks like all my modifications are gone. Is there any way to recover them?

My git reflog looks like this:

57d731c HEAD@{0}: rebase: aborting
d2d3738 HEAD@{1}: rebase -i (start): checkout david
57d731c HEAD@{2}: commit: My commit message

回答1:

You can only recover if you have added the content even if you did not commit. But if you did not even added the changes to the staging are you cannot recover those changes unless you use IDE and the IDE has local history of your changes.

git start to track file once they are in the stage area and not while they are untracked.

The local history exists in all the majors IDEs.



回答2:

If you didn't commit those modifications during the rebase, they unfortunately will be irrevocably lost.



回答3:

It's better to use git stash before git rebase. git stash pop can easily take you where you were.