Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD
?
While I was working on a local project, I wanted to move it to GitHub and then created a new repository. While I was trying to add all these files to the new repository with .gitignore, I accidentally added a wrong file and then tried to clear it.
I ran git reset --hard origin/master
:P
Then all of my local files deleted because the repo was empty. I thought everything was gone.
This saved my life:
git reflog show
git reset HEAD@{1}
git push
Hope it saves another life.