-1

Sorry for bothering everyone! Please help.

I wrongly used the git rebase --hard and overwrite all local files. Then I use git reflog and git reset --hard but did not find the former version! I searched for many questions but it seems that they only deal with git rebase without --hard.

How could I find the deleted files! Thanks!


I checked again and found that I used git pull --rebase. Sorry for misunderstanding.


Command sequences: git stash -> git pull --rebase -> git reset --hard with id (failed) -> git stash apply (succeed)

stander Qiu
  • 122
  • 10
  • 3
    `git rebase` does not have an option `--hard`, that's why you haven't found any questions mentioning it. For git **reset** --hard, there are plenty: https://stackoverflow.com/search?q=%5Bgit%5D+%22git+reset+--hard%22+recover – IMSoP Jan 11 '23 at 11:07
  • 1
    `git rebase` doesn't have option `--hard`. Did you mean `git reset --hard`? – phd Jan 11 '23 at 11:08
  • @IMSoP Sorry, I found that I used `git pull --rebase` – stander Qiu Jan 11 '23 at 11:13
  • @phd sorry I found that I used `git pull --rebase` – stander Qiu Jan 11 '23 at 11:14
  • `git pull` wouldn't pull if there're uncommitted changes in the working dir so you most probably stashed them. Just unstash them back with `git stash pop`, – phd Jan 11 '23 at 11:18
  • 1
    Please can you [edit] the question to show the exact sequence of commands you ran. Don't worry about showing which parts you've edited, anyone curious can see [previous revisions of the question](https://stackoverflow.com/posts/75081926/revisions), just make it as clear as you can for somebody reading the question. – IMSoP Jan 11 '23 at 11:23

1 Answers1

3

If you did not use stash to take snapshots before the reset --hard, there is unfortunately nothing you can do to restore your lost working tree.

Pierre
  • 2,552
  • 5
  • 26
  • 47
Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79