Search code examples
gitgithubgit-reset

does git reset HEAD^ --hard delete everything?


I was finished a project, I got a merge conflict, so I stupidly ran git reset HEAD^ --hard and now all my files are gone except my node modules folder (which was in .gitignore). Is there anyway I can recover my files?

I'm using VScode


Solution

  • As zerkms well said, you haven't lost everything yet, git closely follows what was done, so you can search for your commit via:

    git reflog

    And when you find the one that references your lost work just do

    git reset --hard <commit-ref>

    You can check if your stuff is there by git show HEAD

    Here is a more in depth guide: http://effectif.com/git/recovering-lost-git-commits