What if there were changes, but I did not commit them. And I decided to delete the last 2 commits with the git reset --hard HEAD~2 command. Is it possible to somehow return the files that were before git reset ?

Reported as a duplicate member Nick Volynkin Jan 8 '17 at 10:36 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • What did git add do? - Nick Volynkin
  • unfortunately not - mrchebik
  • Then there is only a chance to find them in temporary files of a text editor or development environment. But the last two commits can be restored by looking in the git reflog . In the future, in order not to lose just so unsaved changes, delete them only with the help of git stash , the details in the question on the link above and here in this: How to return (roll back) to an earlier commit? - Nick Volynkin
  • one
    Oh my goodness, thanks. History of changes is in the editor - mrchebik
  • Got a good editor) - Nick Volynkin

1 answer 1

Means git is impossible. --hard changes the working copy.