Reputation: 31
I made some changes in my local working directory, I forget to save/commit them, but I command git reset HEAD~1
to go back to my previous commit. How do I recover my local work?
Upvotes: 0
Views: 25
Reputation: 52236
If you only ran git reset HEAD~1
(without using --hard
), git
hasn't changed to content of your files on disk. You can check that, in your IDE, your files still contain the modifications you had before your reset
command.
The only things that changed are :
the active commit : you can come back to your previous state by inspecting git reflog
to see what was the <sha>
of the commit before your git reset HEAD~1
action, and run git reset <sha>
your staged files : git reset
has unstaged your staged files if you had any, and there is no easy way to get back their state.
If you rang git reset --hard
, then unfortunately @Code-Apprentice's comment applies : git has reverted the content on disk without saving it first. Check if you have a history of your files in your IDE, or use a file restoration tool for your OS.
Upvotes: 1